For classes, you can use either public or default:

Modifier Description  
public The class is accessible by any other class  
default The class is only accessible by classes in the same package. This is used when you don't specify a modifier. You will learn more about packages in the Packages chapter  

For attributes, methods and constructors, you can use the one of the following:

Modifier Description  
public The code is accessible for all classes  
private The code is only accessible within the declared class  
default The code is only accessible in the same package. This is used when you don't specify a modifier. You will learn more about packages in the Packages chapter  
protected The code is accessible in the same package and subclasses. You will learn more about subclasses and superclasses in the Inheritance chapter

 



Practice Excercise Practice now