Access modifiers are used to set level of access to

— Methods

— Variables/Members

— Classes

These can be Private, Public or  Protected.


Private members of a class can be accessed by methods of that class only.

Subclass cannot access private members of superclass directly. It can be done using getters and setters.

Same applies to private methods and Constructors. If a Constructor is private, it cannot be instantiated from outside the class.

Classes and interfaces  cannot be private.


Public members of a upperclass can be accessed directly by any class (in the same package).

Same applies to public method, constructor and interface.


Protected members of a superclass can be accessed directly by subclass (in any package) and all classes in the same package but not from elsewhere.

If no modifier is used, its treated by default in nature and entities are accessible within the same package.