File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes jdiscuss mock exam on 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 "jdiscuss mock exam on overloading" Watch "jdiscuss mock exam on overloading" New topic

jdiscuss mock exam on overloading

Aaron Anders
Ranch Hand

Joined: Dec 30, 2002
Posts: 39
hello folks,

question: An overloading method must have a diferent parameter list and same return type as that of the overloaded method.
answer: false
explanation: There is no restriction on the return type. If the parameters are different then the methods are totally different (other than the name) so their return types can be anything.

well... isn't it violate the rule of overloading if the return type is different?
so, is the answer "true"?
Sridhar Srikanthan
Ranch Hand

Joined: Jan 08, 2003
Posts: 366
the answer they gave is correct....
what you are talking about is overrirding
in overloading return type doesnt matter as long as the variable list or order or number changes
Hope this helps
Jasper Vader
Ranch Hand

Joined: Jan 10, 2003
Posts: 284
no, it doesen't matter whether the return type is the same or different; when you are overloading, the parameters must be different.
if you are overriding the parameters must be the same and the return type must be the same.

giddee up
Aaron Anders
Ranch Hand

Joined: Dec 30, 2002
Posts: 39
uh, oh...
i'm confused the question with the rule "you can't overload with same signature but different on return type"
so, the answer provided is correct.
thanks for replying!
I agree. Here's the link:
subject: jdiscuss mock exam on overloading
It's not a secret anymore!