• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Rules Roundup #20 (vague wording)  RSS feed

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
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
Gold Digger
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.
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!