This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

means Polymorphic method call

 
Shalini Gupta
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the meaning of Polymorphic method call. Is it the way when super class reference contains sub class object and we try to call overridden method through that ?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that would be polymorphism.

Please change your display name to ensure that you have a valid first and last name
 
Shalini Gupta
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes I will do that. Actaully it is Shalini Gupta
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well there are two type of Polymorphism...
One is static and the other is dynamic.

A static polymorphism is implemented by overloading.

Dynamic polymorphism is implemented by the same way that you said. You create an instance or reference of a super class and initialize it with a sub class. Then you call a method that is overriden in the sub-class. The method which is actually called at run-time is dependent on the actual type of the object stored in reference.

This is an example-


If you execute this program like this
java MainClass 1
The output will be Derived1

If you execute this program like this
java MainClass 2
The output will be Derived2

If you execute this program with any other argument
java MainClass me
The output will be Base

So the call to the display method will be resolved at runtime.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64185
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Shalini Gupthaaaaaa", please check your private messages for an important administrative matter.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic