Polymorphic: The reference to the parent class is directed to the object of the child class.
* Reference to Parent class: One refers to the parent class variable pointing to that memory space
* Two: The parent class has its own type information table, which is owned by any object, and is independent of inheritance polymorphism.
* Subclass object: One refers to the heap memory space of the subclass
* Two: Also refers to the subclass of the Type information table
* Polymorphic (Upward transformation): is to invoke the parent class object's type information table to call the subclass Type information table and the same member method of the parent class
* So-called same, that is, before subclasses overwrite/override parent class methods
* A member method that is not in the parent class information table is not called.
* static method, static data, member variable and this is irrelevant. The parent class reference accesses all variables and methods in the parent type, whether it is a member or a static
* Parent Class A = new subclass (); What do you want to know about the parent class object?
* After a downward transformation, replace the type information table of the parent class with the subclass's type information table, so that all the variables and methods in the seat class object can be completely
* Parent Type Information table access,
* After the transition, access the sub-type information table
* Do not transform, you can access the member methods in the subclass after overwrite
*
Note
* Polymorphism in the client class and class library class differences
* Client class: The class that contains main () is called the client class
* First in the class library class, there is an inheritance relationship, and the subclass overrides the method of the parent class
* Then, in the client class, point to the object of the child class with a reference to the parent class
In Polymorphic, only member methods are involved
* Member variable: not involved
* Construction method: Does not inherit at all, so it does not involve
* Static method: Static method also does not inherit, belong to the whole type
The polymorphism of Java