Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rules Roundup #20 (vague wording)

 
Yuri Sforza
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a private method of a superclass
be declared within a subclass?

The answer given is YES and explanation says
that "Private methods cannot be overriden,
but they can be re-declared/redefined in the
subclass..."
OK, but the question was about declare,
not about re-declare. For me they are
different terms. I think that method (whether
private or not) may be declared only once
(in the class in question or somewhere higher
in the inheritance hierarchy). When talking
about subclass, what you can do (or try to do)
is re-declaring, overriding, "declaring method
with the same signature as in superclass", ...
but you cannot say that you are "declaring method
of a superclass".
Am I missing something? Comments anybody?

--
Y. Sforza
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be 100% JLS compliant the wording should be something like this:
"Can a subclass declare a method that has the same signature than a private method in its superclass?"
Note that the access modifier is NOT part of the signature of a method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic