First, verify
(1) the subclass and the parent class define the exact same method
• The result is a., Max,201 ,
• The parent class called a method of the subclass, but the variable called in the method is a variable of the subclass
• Self-Summary: A method in a subclass that calls a subclass if a variable of the same name is called.
Summarize:
• When a subclass has the same method as a parent class, and a parent class variable refers to a subclass object, which method is called, determined by the object's own "true" type, that is, the object is a subtype, it calls the method of the subtype, it is the parent type, and it invokes the method of the parent type.
• This feature is actually a concrete representation of the object-oriented "polymorphic" feature.
• If the subclass has the same field as the parent class , The fields in the subclass are substituted or hidden from the fields of the parent class, and the sub-class method accesses the fields in the subclass (not the fields in the parent class). If the subclass method does want to access a field that is hidden in the parent class with the same name, it can be accessed with the super keyword.
• If the subclass is used as a parent class , the field accessed through the subclass is the parent class !
Java multi-state after-class homework