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 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
Author

overloaded-overriden

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

O/P : ABC

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
Hi,

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.

Thanks,
Raja


SCJP 1.4
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

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

Note:
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.

http://forum.java.sun.com/thread.jspa?threadID=477074&messageID=2215964


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: overloaded-overriden
 
Similar Threads
inheritance
overriding + overloading
Dan's Mock #4 Q. 25
Overloading
overloading problem, pls help!