what is dynamic method dispatch ?
Answer Posted / salman
In dynamic method dispatch,super class refers to subclass object and implements method overriding.
Example:
class Flower {
void which() {
System.out.println("A Beautiful flower.");
}
}
class Rose extends Flower {
void which() {
System.out.println("Rose");
}
}
class Lotus extends Flower {
void which() {
System.out.println("Lotus.");
}
}
class Test {
public static void main(String[] args) {
Flower ref1 = new Flower();
Flower ref2 = new Rose();
Flower ref3 = new Lotus();
ref1.which();
ref2.which();
ref3.which();
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the use of 'super' keyword inside a constructor?
What is object-oriented paradigm?
what is meant by Byte code concept in Java?
What is parsing in grammar?
What is the exact difference in between Unicast and Multicast object? Where will it be used?
how does multithreading take place on a computer with a single cpu? : Java thread
Explain thread in java?
What is a programming object?
Explain about class in java?
Explain importance of inheritance in java?
What are the types of java?
What is byte code and why is it important to java’s use for internet programming?
What if I write static public void instead of public static void in java?
What is the basic difference between string and stringbuffer object?
Why vector is used in java?