what is dynamic method dispatch ?
Answer Posted / hasib reza
Determining at runtime, which overridden method to call, is called dynamic method dispatch.
This is how Java implements run-time polymorphism.
Whenever a method is called on an object reference,
Declared type of object reference is checked at compile time to make sure the method exists in declared class.
At run time, the super class objects reference could refer to an instance of any subclass of the declared reference type.
When an overridden method is called through a super class reference,
Java determines which version of that method to execute based upon the type of object being referred.
When different types of objects are referred to,
Different versions of an overridden method will be called.
It is the type of the object being referred to
Not the type of the reference variable
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Can a class extend 2 classes in java?
Define how destructors are defined in java?
What is a stringbuilder?
How can a gui component handle its own events in java programming?
What is the argument in java?
What is an immutable class? How to create an immutable class?
Can we sort array in java?
Difference difference paint() and paintcomponent()?
Write a program in java to create a doubly linked list containing n nodes.
Why do we need hashset in java?
What is use of a abstract variable?
Explain the use of javap tool.
What are the advantages of exception handling in java?
What is an interface in java?
Explain the importance of import keyword in java?