This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Strange o/p.Polymorphism in Overrided method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Strange o/p.Polymorphism in Overrided method?" Watch "Strange o/p.Polymorphism in Overrided method?" New topic
Author

Strange o/p.Polymorphism in Overrided method?

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344


For the above pgm, how the o/p is: AAA

In all the three classes m1 has been overrided and polymorphism will come to play. so the below line
A3 a4 = new C3();
ref var is A3 and resolved at compile time, but while run time it has to call the C3 object's m1() only.. how it's calling A3 object's m1()?


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Notice there is no overriding because the methods do not have the same signatures.
Satish Kota
Ranch Hand

Joined: Feb 08, 2006
Posts: 88
You are not overriding you are overloading the methods. And which methods to be called will be determined by the referenced type


SCJP 5.0 77%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange o/p.Polymorphism in Overrided method?
 
Similar Threads
Dan's Mock #4 Q. 25
overloaded-overriden
overriding + overloading
Sub-class confusion...I thought I understood
Overridiing