This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

means Polymorphic method call

 
Shalini Gupta
Greenhorn
Posts: 11
  • 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
  • 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
  • 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: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 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: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Shalini Gupthaaaaaa", please check your private messages for an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic