1. Inheritance
Inheritance is the child class inherits the characteristics and behavior of the parent class, so that the subclass object (instance) has the parent class's instance domain and method, or the subclass inherits the method from the parent class, so that the subclass has the same behavior as the parent class.
Java classes have four access control characters: private, default, protected, and public, (default is not written) and there are four levels of access control altogether.
The property or method of private modification is unique to the class and cannot be accessed directly in any other class;
The property or method of the default adornment has a package access attribute, and other classes in the same package can be accessed;
Protected modified properties or methods can be accessed by other classes in the same package, but also for subclasses that are not in the same package;
Public-decorated properties or methods can be accessed directly in the outer class.
When a subclass inherits from a parent class, the subclass can inherit properties and methods that have non-private adornments in the parent class, which can be called by super when the child class object wants to invoke the original method of the parent class . Subclasses are not inherited for properties and methods that are unique to the private decorated parent class.
Subclasses can have their own properties and methods, that is, subclasses can extend the parent class.
Subclasses can implement methods of the parent class in their own way.
When a subclass needs to change the inherited method, that is, overriding the parent class ( which must have the same parameter return type ) Once overridden, this method of the parent class behaves as hidden for the subclass. After the object of the subclass calls this method, it is called after the subclass overrides the method.
2. This and super in succession:
The This in the method represents the object reference that is currently calling this method
Use this when a method in an object needs to call other methods in this object
When the name of the local variable in the object property and method is the same, sometimes this can handle the case where the member variables and the names of the parameters in the method are identical.
This can be thought of as a variable whose value is a reference to the current object
Super represents calling the corresponding properties and methods in the parent class.
Inheritance in Java