Search

// 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


Share this article :
 

Post a Comment

 
Support : everytricks4.blogspot.in/ | Johny Template | Mas Template
Copyright © 2011. Computer Tricks - All Rights Reserved
Creating Website Published by
Proudly powered by Blogger