Skip to content

Java Access Modifiers

Estimated time to read: 1 minute

Overview

In Java, attributes and methods are assigned an accessibility.

Accessibility determines whether other Java objects can access that attribute or method.

Levels of Accessibility

Java provides four levels of accessibility: |

Access Level
|
Description
| | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | private | Accessible only to the class in which it is defined | | default (Package Scope) | Default allows access to classes in the same package but does not allow access to sub-classes unless they are in the same package | | protected | Accessible in the class itself, subclasses and all classes in the same package | | public | Accessible to any class, in any package |