Access modifiers are hinder the access of classes, interfaces, and variables. There are four types of access modifier in Java:
- Public: The classes, interface, and constructors are accessible anywhere.
- Private: The classes, interface, and variables are accessible only inside the class in which it is defined.
- Protected: The classes, interfaces, and variables are accessible only inside the classes where it is inherited.
- Default: It is defined inside the complete package where it is defined.