Explain the access control modifiers?

: 192
Paper : Java FAQ (Frequently Asked Questions and answers) for freshers | Platform : Object-oriented programming Language | Category : Programming FAQs

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.