Method Overloading Contd
Method Overloading Contd
Method Overloading Contd
class OverloadDemo {
public static void main(String args[]) {
Overload ob = new Overload();
int resI;
double resD;
ob.ovlDemo(2);
System.out.println();
MyClass() {
System.out.println("Inside MyClass().");
x = 0;
}
MyClass(int i) {
System.out.println("Inside MyClass(int).");
x = i;
}
MyClass(double d) {
System.out.println("Inside MyClass(double).");
x = (int) d;
}
MyClass(int i, int j) {
System.out.println("Inside MyClass(int, int).");
x = i * j;
}
}
Overload constructor contd.
class OverloadConsDemo {
public static void main(String args[]) {
MyClass t1 = new MyClass();
MyClass t2 = new MyClass(88);
MyClass t3 = new MyClass(17.23);
MyClass t4 = new MyClass(2, 4);
class SumDemo {
public static void main(String args[]) {
Summation s1 = new Summation(5);
Summation s2 = new Summation(s1);