Types of access modifiers in Java?

Java 8Object Oriented ProgrammingProgramming

Java provides four types of access modifiers to set access levels for classes, variables, methods, and constructors. Following are the access levels -

  • default - Visible to the package. No modifiers are needed.

  • private - Visible to the class only.

  • public - Visible to the world.

  • protected - Visible to the package and all subclasses.

Updated on 24-Feb-2020 06:03:03