1. Private: In the same class
2. Default: Classes in the same package
3. Protection: In a class subclass in the same package (inheritance)
4. Public: No scope
When you create subclasses and override methods, you must consider the access control of the original method:
As a general rule, the overriding method is that the access control of the new method cannot be more restrictive than the original method, but it can be more loose.
Access control involving methods:
1. methods that are declared public in a superclass must also be common in subclasses;
2. A method declared as protection (protect) in a superclass can be protected (protect) or public in a subclass ( public), but cannot be private.
3. Methods that do not have access control in the superclass can be more restrictive in their access control in subclasses, or they can be relaxed.
Java Access control variables