File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Inherit private member Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inherit private member" Watch "Inherit private member" New topic
Author

Inherit private member

C WL
Greenhorn

Joined: Feb 02, 2003
Posts: 3
The following two classes are modified from the book of Khalid and Rolf

As we know, all members from superclass should inherited to subclass. However, from the above example, TubeLight cannot inherit the private members. Furthermore, if I changed the accessibility of the private members from the superclass Light to default/protected, the TubeLight class actually run the Light() constructor. Why this is the case

(Marilyn added code tags)
[ February 02, 2003: Message edited by: Marilyn de Queiroz ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
Originally posted by C WL:
From the above example, TubeLight cannot inherit the private members.

Yes, private members are not inherited.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Java knows four access modifier: private protected, public and a default (there exists no
word for it)
private is only accessible in instances of the class.
public is accessible by every class/object
protected is like private, but can be inherited
default can be accessed from objects in the same pakage.
Hope this helped
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inherit private member