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 Overriding Methods 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 "Overriding Methods" Watch "Overriding Methods" New topic
Author

Overriding Methods

Kaushal Shah
Greenhorn

Joined: Jul 20, 2004
Posts: 4
Hello friends,

I was doing the 'Single Topic' tests on http://www.danchisholm.net/july21/topic/index.html, and stumbled upon one of the asnwers provided there.

I would like to know if there is a mistake in 1 of the answers....

A sentence in the answer to Qn. No. 7 reads as:
... A subclass method may not have weaker access than the overridden superclass method. ...

Isnt it that: the access modifier for the overriding method may not be more restrictive than the access modifier of the superclass method ?
implying:
- if the superclass method is public, the overriding method must be public
- if the superclass method is protected, the overriding method may be protected or public
- if the superclass method is package, the overriding method may be packagage, protected, or public
- if the superclass methods is private, it is not inherited and overriding is not an issue

So, shudnt the answer read as:
... A subclass method may have weaker access than the overridden superclass method. ...

(or)

... A subclass method may not have stronger access than the overridden superclass method. ...

Cheers,
Kosh!
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
This looks like a question about semantics. What does Dan mean by "weaker?" I think it can be interpreted either way, really (correctly or incorrectly). My suggestion would be to simply rephrase the answer.


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding Methods