aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Private methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Private methods" Watch "Private methods" New topic
Author

Private methods

Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Can they be overridden???
Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Right, so despite the fact that it looks like an override, it is not. Is that what you are saying?
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
What? Private method is not inherited? Are you sure?
Aru Ven
Ranch Hand

Joined: Sep 28, 2000
Posts: 199
Sam,
I think PRIVATE methods are not inherited. ANd can't be OVERRIDDEN coz they belong only to the class that declares them & not to the class that extends them.
Aruna
Sam Wong
Ranch Hand

Joined: Dec 07, 2000
Posts: 133
Ack! I think I got it now. Private members and all constructors are not inherited by subclasses. How does this affect overriding? I'm not sure. I'm back to my original statements. Funny how RHE implies that private members are inherited. p.79 and p.83. It states that private methods can be overridden by private, default, protected or public methods. So if a private method is not inherited, does defining the exact same method be considered overriding? I guess so. Overriding is basically redefining the method. I suppose this is true whether the overridden method is private or otherwise. So I guess the answer to the question is yes.
[This message has been edited by Sam Wong (edited December 14, 2000).]
Sam Wong
Ranch Hand

Joined: Dec 07, 2000
Posts: 133
Thanks for clearing things up, everyone. Good topic. Got me all confused.
Rajiv Ranjan
Ranch Hand

Joined: Sep 28, 2000
Posts: 61
Private methods are not inherited and also cannot be overridden.
If you declare a method with the same name as the private method in any subclass it is entirely a new method.
Rajiv
Sam Wong
Ranch Hand

Joined: Dec 07, 2000
Posts: 133
Ok, now its all clear. Thanks.
 
 
subject: Private methods