Course
Sr. No. Name of the Experiments Outcome
s
1 Write a program for different operators used in Java using class and object. CO1
2 Write a program to show use of if…else for Decision Making in Java
CO1
3 Write a program for different Loop Control Structures structure statements in
Java CO2
4 Write a java program to show use of inbuilt String Class Functions in Java. CO2
5 Write a java program to show Method overloading in Java CO3
6 Write a java program for the implementation of inheritance in Java.
CO3
7 Write a java program for the implementation of Exception Handling in Java CO4
8 CO5
//Name:
Roll Number:
Cluster:
// Demonstrate method overloading.
class OverloadDemo {
void test() {
[Link]("No parameters");
// Overload test for one integer parameter.
void test(int a) {
[Link]("a: " + a);
// Overload test for two integer parameters.
void test(int a, int b)
{ [Link]("a and b: " + a + " " + b);
// overload test for a double parameter
double test(double a) {
[Link]("double a: " + a);
return a*a;
public static void main(String args[]) {
OverloadDemo ob = new
OverloadDemo(); double result;
// call all versions of test()
[Link]();
[Link](10);
[Link](10, 20);
result = [Link](123.25);
[Link]("Result of [Link](123.25): " + result);
}
}
class StringDemo2 {
public static void main(String args[]) {
String strOb1 = "First String";
String strOb2 = "Second String";
String strOb3 = strOb1;
[Link]("Length of strOb1: " + [Link]());
[Link]("Char at index 3 in strOb1: " + [Link](3));
if([Link](strOb2))
[Link]("strOb1 == strOb2");
else
[Link]("strOb1 != strOb2");
if([Link](strOb3))
[Link]("strOb1 == strOb3");
else
[Link]("strOb1 != strOb3");
// Demonstrate multiple catch statements.
class MultiCatch {
public static void main(String args[]) {
try {
int a = [Link];
[Link]("a = " + a);
int b = 42 / a;
int c[] = { 1 };
c[42] = 99;
} catch(ArithmeticException e) {
[Link]("Divide by 0: " + e);
} catch(ArrayIndexOutOfBoundsException e)
{ [Link]("Array index oob: " + e);
[Link]("After try/catch blocks.");