File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method overriding 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 "method overriding" Watch "method overriding" New topic
Author

method overriding

maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 186
why is superclass method called???
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Because you're not overriding the method get and you're using a reference of type SuperCafe4Java.

Don't forget to Quote Your Sources


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
this is method overloading.
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268


try @Override, it confirms if it is overriding or not.

Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

maggie joseph wrote:why is superclass method called???


because you are not overriding the method, you are overloading it.
remember the rule of overriding the number of parameter(s) and the type of parameter(s) must be same where the return type can be co-variant of an overridden method.


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: method overriding
 
Similar Threads
covariant doubt
Can Any Explain This Code...
Overloaded method
covariant data types and overloaded method
Covariant Return Types Mock from www.cafe4java.com