• Post Reply Bookmark Topic Watch Topic
  • New Topic

Polymorphism  RSS feed

 
Sathya Shanmugam
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

could anyone give some explanation with example for the statement below

"Polymorphic method invocation apply only to the overridden instance methods"

thanks for your help in advance
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See How My Dog Learned Polymorphism, and let us know if that clears it up.
 
Harshada Deshmukh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Its true
see the following code inwhich sound method(instance method) is overidden which shows polymorphism



EDIT by mw: Added Code Tags. (See how much better that looks? )
[ March 28, 2007: Message edited by: marc weber ]
 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding to the excellent replies aboved, I would just add one small point: the quote also seems to be tesing the programer for a well-known java pitfall: remember that polymorphism works only for overridden *instance* methods... i.e. it does *not* work for *static* methods.

Example:

[ March 29, 2007: Message edited by: Sol Mam-Orn ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!