i

JAVA Complete Course

Understanding The Access Controls

In java by using the access specifiers, developers can control the accessibility of class member variables and methods. Java's access specifiers are public, private, protected and a default access level.

Public class member can be access from any other point of application. It means that our public variables or methods are visible for everyone.

Private access members can be accessed only inside the class, but not from outside of class.

Default access member is accessible from any other class inside same package. Please note, that default is not keyword and if we don’t specify any access modifier to our methods or variables, they have default access control.

Protected variables and methods are accessible from any class inside same package, like default, and in its subclasses.