Access Specifier is also known as Access Modifier. It specifies the scope of class and other members. When we use particular specifier, it decides whether the class, method or variable will inherit or not.
Access Specifier types:
Private:
When we use Private keyword before class, method or variable, that things cannot be inherited in other class or package. everything will become private.
default:
When we do not use any keyword before class, method or variable, default specifier is there. When we use default specifier, our class, method or variable can be used in same class as well as in other class i.e child class. We can use that things in other class of same package. In simple words, when we will use default specifier we can use it in same package only.
Protected:
When we use protected keyword before class, method or variable, we can use that things in classes of same package as well in other class of other. But we can use that things only in sub class other package. Sub-class means parent class of package.
Public:
When we use public specifier, we can use our class, method or variable everywhere. Our class, method or variable can inherit everywhere, in all classes of same package as well as in other package.
Uses:
It helps us to restrict the scope or visibility of a package, class, constructor, methods, variable or other data members.
To assign the accessibility to the class members.