(1) If the subclass and the parent class are within the same package, the subclass can inherit all member variables and methods except private for the parent class, and the permissions will not change;
(2) If the subclass and the parent class are not within the same package, the subclass can inherit the member variables and methods of the public and protected permissions of the parent class, and cannot inherit the friendly and private;
(3) Further explanation of protected:
If there is a Class A, Class B is a subclass of Class A, Class C is a subclass of Class B, then Class C inherits the member variables and methods of Class A protected;
If the class C itself creates an object, you can use this object to access the inherited or own defined protected member variables and methods;
If you create an object in another class: for Class C's own defined member variables and methods, as long as the other class and Class D are in the same package, you can access the custom protected through the objects created by Class D;
For Class C inheriting from the parent class, the protected is traced back to the Ancestor class Class A, and if the other class and a are similar, the inherited protected can be accessed through the object.
(4) Hide and rewrite: The member variables of the subclass are the same as the members of the parent class, and the members that inherit from the parent class are hidden, and the methods that inherit from the parent class can be hidden by overriding the methods that inherit from them After hiding, you want to call a method that inherits from the parent class with the keyword super. Subclasses override the parent class method, and access permissions can be increased or unchanged, but must not be reduced.
(5) Final keyword: Final decorated class, class cannot be inherited; final modifier, method cannot be overridden; final modifier variable, variable is constant, must assign initial value.
Summary of Java subclass inheritance and final issues