my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overriding and Overloading. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overriding and Overloading." Watch "Overriding and Overloading." New topic
Author

Overriding and Overloading.

Rohit Ramachandran
Ranch Hand

Joined: Oct 05, 2010
Posts: 102


I was under the impression that the output would give "Super Super" since for Overriding it's the type of the reference variable that counts.

However, the output I'm getting is 0.0 and 9.0
Rohit Ramachandran
Ranch Hand

Joined: Oct 05, 2010
Posts: 102
Is it the object type or reference type that determine which method is to be called in-
1)Overriding?
2)Overloading?

Thank you.
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 440

Reference type determines which overloaded method to be called at compile time
Object type determines which overriding method to be called at run time


SCJP 6 [86%] June 30th, 2010
OCPWCD [84%] March 26th, 2012
OCEJPAD [83%] September 6th, 2014
If you find any post useful, click the "plus one" sign on the right
Rohit Ramachandran
Ranch Hand

Joined: Oct 05, 2010
Posts: 102
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Overriding and Overloading.