Studyon Minte9.com
Fundamentals (Docs)

Study

Access level modifiers



Access level modifiers determine whether other classes can use a particular field or invoke a particular method.

If a class has no modifier (the default, also known as package-private), it is visible only within its own package. 
Packages are named groups of related classes.

For members, there are two additional access modifiers: private and protected. 
The private modifier specifies that the member can only be accessed in its own class. 
The protected modifier specifies that the member can only be accessed within its own package, and, 
in addition, by a subclass of its class in another package.

The following table shows the access to members permitted by each modifier.

	Modifier 	Class	Package		Subclass 	World
	---------------------------------------------------------------------------------
	public         Y            Y 		          Y 		Y
	protected 	  Y 	        Y 		          Y 		N
	no modifier  Y 	        Y 		          N 		N
	private 	  Y 	        N 		          N 		N

Use the most restrictive access level that makes sense for a particular member. 
Use private unless you have a good reason not to.
Avoid public fields except for constants.
Public fields tend to link you to a particular implementation and limit your flexibility in changing your code.


http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html