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
Wha is the output from system.out.println(“hello”+null); ?
What is the maximum size of array in java?
Explain the difference between protected and default access.
Why is the type for real numbers called double?
How define set in java?
What is the constructor?
What do you mean by hashing?
Explain throw keyword in java?
What is number data type?
What is the size of boolean variable?
Write an algorithm program in java for the following question.. 1) S is a set of integers.X is an integer obtained by sum of two digits in S. Write logic for whether or not the X is from the S. The time of algorithm should not exceed o(n logn).
Can abstract class have private constructor?
What are synchronized methods ?
How do you add an element to a hashset in java?
What is outofmemoryerror in java?