Answer Posted / manishsoni
class A
{
void callme()
{
System.out.println("Inside A's callme method");
}
}
class B extends A
{
void callme()
{
System.out.println("Inside B's callme method");
}
}
class C extends A
{
void callme()
{
System.out.println("Inside C's callme method");
}
}
class Dispatch
{
public static void main(String args[])
{
A a = new A(); // object of type A
B b = new B(); // object of type B
C c = new C(); // object of type C
A r; // obtain a reference of type A
r = a; // r refers to an A object
r.callme(); // calls A's version of callme
r = b; // r refers to a B object
r.callme(); // calls B's version of callme
r = c; // r refers to a C object
r.callme(); // calls C's version of callme
}
}
MoNu
| Is This Answer Correct ? | 7 Yes | 2 No |
Post New Answer View All Answers
What is basic syntax?
what is enumset?
Tell some latest versions in JAVA related areas?
Is java hard to learn?
Is passing by reference faster?
How can we run a java program without making any object?
What is difference between word and integer?
What is the difference between object oriented programming language and object based programming language?
What programs use java?
Why wait(),notify(),notifyAll() methods defined in Object class althought we are using in only threads.
What is difference between calling start() and run() method of thread?
What is formatted output?
Why is the main method static?
What is the difference between variable & constant?
What is a function argument in java?