Access Modifiers are used to define the scope of classes, variables, methods or constructers. Access Modifiers in Java are used to set the access- level of data.
1. Default: Java adds a default modifier in case no access modifier is declared by the programmer.
2. Public : Can be accessed globally across packages.
3. Private: Can be accessed within same class only.
4. Protected: Can be accessed via Inheritance only i.e. extending the class.
private keyword is mostly used for variables, constructors and methods not classes as a private class makes no sense.
The protected access modifier is accessible within package and outside the package but through inheritance only.
The protected access modifier can be applied on the data members, methods and constructors. It can’t be applied on the classes and interfaces.
Y- Accessible N- Not Accessible
Basic Java Tutorials: