File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "protected and package/default access" Watch "protected and package/default access" New topic

protected and package/default access


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,
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... ;-)

I agree. Here's the link:
subject: protected and package/default access
It's not a secret anymore!