ISFP interview question

What are the various access specifiers for Java classes?

Interview Answer

Anonymous

Feb 12, 2023

1. Private: When a variable is declared as private, it can be accessed only from the same class to which they belong. 2. Public: Methods and variables that have public access can be accessed by all the other classes in the project. 3. Protected: When a variable is declared as protected it means that it can be accessed within the same package classes and subclasses of any other packages. 4. Default: Methods and variables can be accessed only from the same package and not from outside of its native package.