Java offers four access specifiers
Public: public classes, methods, and fields can be accessed by every class.
Protected: protected methods and fields can only be accessed within the same class to which the methods and fields belong.
Default (no specifier): when we do not set access to specific level, then such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs.
Private: private methods and fields can only be accessed within the same class to which the methods and fields belong. Private methods and fields are not inherited by subclasses.