File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding Methods

 
Kaushal Shah
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic