DOWNLOAD

Get our toolbar!

Saturday, 30 April 2011

// Write a program in java in which derived class uses attributes of base class.


CODE

class Overload
{
public void test(int a) {
System.out.println("a: " + a);
}
void test(int a, int b) {
System.out.println("a and b: " + a + "," + b);
}
double test(double a) {
System.out.println("double a: " + a);
return a*a; }
}
class Over extends Overload {
void test(int a, int b) {
System.out.println("a and b: " + a + "," + b); }
}
class MethodOverloading {
public static void main(String args[]) {
Over overload = new Over();
double result;
overload.test(10);
overload.test(10, 20);
result = overload.test(5.5);
System.out.println("Result : " + result);
}
}

OUTPUT DISPLAY


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More