• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Method Dispatch

 
rahul sengupta
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 295
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Just to add on Ritchie's reply , polymorphism will not allow you to override either static, private or final method.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic