This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes protected and package/default access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "protected and package/default access" Watch "protected and package/default access" New topic
Author

protected and package/default access

FELIX ALE
Greenhorn

Joined: Apr 08, 2005
Posts: 2
What is the major difference between protected and package/default access specifiers, someone should help me please.
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
protected is less restrictive than the default and allows visibility to subclasses outside the package of the superclass. Default only allows access to subclasses within the same package as the superclass.


SCJP 1.4, www.gsi3d.org.uk
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
Protected works between packages and default works only in the same package.
this is the simplest explanation I can think of.


Life called,so here I am.<br />Cheers<br />Niki.:-)
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
When I studied Java for the exam, I used a book which called the default accessor "package private". this name really tells a lot... ;-)

greets,
jan.
 
wood burning stoves
 
subject: protected and package/default access