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
What's the access scope of protected access specifier?
How will you calculate the depth of a binary tree if the tree contains 15 nodes?
What are the types of inner classes (non-static nested class) used in java?
Difference between notify() method and notifyall() method in java?
How do you ensure that n threads can access n resources without deadlock?
How do you make a thread in java?
In which order the iterator iterates over collection?
Can we serialize arraylist in java?
What is a Transient Object?
Can java list be null?
os is developed in c no java is more secured then c na why dont the os developed is developed using java
What is OOP's Terms with explanation?
Explain java code for recursive solution's base case?
What is method in java with example?
How do you sort a string in java?