What are the various access specifiers for Java classes?

Access specifiers for Java

Last updated:8/27/2019 3:07:51 AM

1 Answers

Shrikant Mishra
Shrikant Mishra

Into the Java, access specifiers are the keywords used before a class name which defines the access scope. The types of access specifiers for classes are:

  • Public: Class, Method, Field is accessible from anywhere.
  • Protected: Method, Field can be accessed from the same class to which they belong or from the sub-classes, and from the class of the same package, but not from outside. 
  • Default: Method, Field, the class can be accessed only from the same package and not from outside of its native package. 
  • Private: Method, Field can be accessed from the same class to which they belong.

Answer