permaculture playing cards
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes overloaded-overriden 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 "overloaded-overriden" Watch "overloaded-overriden" New topic


Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026


Class B extends class A and Class C extends class B, therefore method m1() is overdidden right?.
But according to the output, method m1() is overloaded. Some one please explain how method m1() is overloaded and not overridden.

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Rajasekar Elango
Ranch Hand

Joined: Sep 13, 2004
Posts: 105

Here the method m1() in subclasses B and C overloads the method m1() inherited from its parent class A.

Overridding methods should have same method signature, both method parameters and return type should be same.


SCJP 1.4
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1850

method parameters are it is method overloading.Overridden method signature must be same.

In Java 1.5 the return type of the overriding method can be different.
When you override a method, the declared return type can be any subclass of the the class returned by the original method. Currently, the method signature of an overriding method has to match exactly that of the method that it is overriding, including the return type.

Krishna Srinivasan
OCAJP 7/8 Exam, 400+ OCPJP Mock Questions
I agree. Here's the link:
subject: overloaded-overriden
It's not a secret anymore!