| 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.
|
 |
 |
|
|
subject: Overriding Methods
|
|
|