File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes means Polymorphic method call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "means Polymorphic method call" Watch "means Polymorphic method call" New topic

means Polymorphic method call

Shalini Gupta

Joined: Aug 06, 2008
Posts: 11
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

Joined: Feb 24, 2006
Posts: 6662

Yes that would be polymorphism.

Please change your display name to ensure that you have a valid first and last name

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Shalini Gupta

Joined: Aug 06, 2008
Posts: 11
yes I will do that. Actaully it is Shalini Gupta
Ankit Garg

Joined: Aug 03, 2008
Posts: 9466

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.

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

"Shalini Gupthaaaaaa", please check your private messages for an important administrative matter.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: means Polymorphic method call
It's not a secret anymore!