This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inheritance: Private Member access from SubClass? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inheritance: Private Member access from SubClass?" Watch "Inheritance: Private Member access from SubClass?" New topic
Author

Inheritance: Private Member access from SubClass?

Davide Crudo
Ranch Hand

Joined: Sep 08, 2009
Posts: 62
Dear All,

I was reviewing the information about access modifiers inherited from subclasses, and reading the following link:

Sun Java Inheritance Documentation

it says:

[...] If the subclass is in the same package as its parent, it also inherits the package-private members of the parent.[...]


a little below it says:


[...]
A subclass does not inherit the private members of its parent class. [...]


And indeed, private members, package or not, are not visible (unless using setters and getters)...

What does "package-private" members refers to?....

Thanks!
Dave


SCJP, SCBCD
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 787

What does "package-private" members refers to?....


it refers to default access that means no access modifier.



SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Davide Crudo
Ranch Hand

Joined: Sep 08, 2009
Posts: 62
...

Now it makes a little more sense... package-private = default... i was confused by the keyword private ;)

Thank you!
Dave
 
Consider Paul's rocket mass heater.
 
subject: Inheritance: Private Member access from SubClass?
 
Similar Threads
Private variables aren't inherited?
khalid mughal
Request to Barry Gaunt and Bert Bates
Overriding
Possible error in K&B book (resolved - no error)