jQuery in Action, 3rd edition
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

method overriding

maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
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%
I agree. Here's the link: http://aspose.com/file-tools
subject: method overriding
It's not a secret anymore!