There is no such kind of terms in java like access specifier or access modifier there is only modifier.
Proof: I have create 1 class and we know that we can’t use private with class name then you can see
Output:
Similarly, like static
These concepts are used to explain the accessibility scope of the class interface data member and function, constructor static, final, abstract.
These are modifiers as well as keyword.
Rule: public=default=protected with in same package.
public: Class, Nested Class, DM, MF, Constructor when use public when you want to take these things out of the package then you should use public.
When use default when you don’t want to take these things out of the package then you should use default.
Private: Nested class, DM, MF, constructor you don’t want to need these things go to outside the class.
Protected: Nested class, DM, MF, constructor when we use protected with these things then it can go outside the package but only in the child class and it can only on the reference of child class only.