| Author |
Dynamic Method Dispatch
|
rahul sengupta
Greenhorn
Joined: Aug 25, 2011
Posts: 8
|
|
Can any of you please help me out with dynamic method dispatch. This is not very clear to me.
If someone can please elaborate on this it will be of great help.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32837
|
|
Welcome to the Ranch
If you search the Ranch, you will find a few references, where people seem to use it similarly to polymorphism. There is something in the Java™ Language Specification, but that is by no means easy to read.
Please explain what people have told you about dynamic method dispatch, and what you think it means. Then we shall know how to answer your question.
|
 |
rahul sengupta
Greenhorn
Joined: Aug 25, 2011
Posts: 8
|
|
First of all thanks a lot.
What I have read is that here run time polymorphism is applied. As it is during the run time that it is decided which method will get overridden and get used.
From another source what I have read is that in normal cases we can use members of the base class through subclass. But in case of dynamic method dispatch we are able to access members of subclass from base class. Is it really the case? I am a bit confused with this explanation.
Thank You in advance
Rahul
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32837
|
|
|
That sounds like a good description of polymorphism. I would remind you that polymorphism and overriding only apply to instance methods, not to static members or instance fields.Complete those classes, check whether I have spelt the methods the same throughout, and execute the last code snippet. Then you can see how it works.
|
 |
Javin Paul
Ranch Hand
Joined: Oct 15, 2010
Posts: 277
|
|
Just to add on Ritchie's reply , polymorphism will not allow you to override either static, private or final method.
|
http://javarevisited.blogspot.com - java classpath - Java67 - java hashmap - java logging tips java interview questions Java Enum Tutorial
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4206
|
|
Javin Paul wrote:
Just to add on Ritchie's reply , polymorphism will not allow you to override either static, private or final method.
Static methods can't be overridden at all.
Private methods aren't inherited so can't be overridden at all.
Final methods can't be overridden at all.
So what's your point re polymorphism?
|
luck, db
There are no new questions, but there may be new answers.
|
 |
 |
|
|
subject: Dynamic Method Dispatch
|
|
|