• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

overriding methods and access

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was reviewing a post by Steven Joseph and have a question which I need cleared up. Given that the amethod in class B attempts to override the base class amethod but can't due to the private access modifier. amethod in Class B is just another method at this point.

RHE certification book gives the rules for overriding as:
private => friendly => protected => public
My confusion comes with the private overriding rule. As the code shows you can't override a private method. At least I don't see how you can. Am I must be missing something here? If it is true that a private method can't be overriden then what could be the reason for giving a rule with private in it? This just seems to cloud the understanding and the private portion should just be stated as such and removed. Because of all these questions, I feel I must not have the concept correct. Hopefully someone with a firm handle on this will set me straight on this. If at all possible please give me an example which where a private method can be overridden to a friendly, protected or public access. Thanks.

(Marilyn added code tags)

[This message has been edited by Marilyn deQueiroz (edited March 05, 2001).]
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems to me you do have a good handle on the concept. Just don't get too hung up on the semantics (or see Java Langauge Specifications for the official wording).
The important thing to remember, which you already seem to understand, is that you can't declare a method to be less visible than a method in the superclass that has the same signature (that means overridden in most cases, I guess).
See also: this thread in the Certification forum
J.Lacar
[This message has been edited by JUNILU LACAR (edited March 06, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic