======= subclasses are instantiated by default when the parent class is empty, the constructor is super (), which can be omitted.
However, when the parent class does not have an empty construction method, it must call this method in the subclass to instantiate the parent class before the instance class is real.
The default constructor for a parent class that is empty is automatically called by default in the subclass.
======== when a parent class refers to a subclass object, it calls different classes based on the class that the instance belongs to in the reference variable, which applies only to methods that do not apply to member variables . simple to understand that Java does not support attribute field overrides (override), only method overrides are supported, and property fields are not overridable.
when ======== instantiates a subclass, it initializes the constructor of the parent class, but does not produce the object . The parent class has the potential to be an interface, not a default call to an empty constructor method. because the subclass must hold the value of the member variable of the parent class, it is initialized and cannot produce an overridden polymorphic effect for member variables.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java polymorphic Example class automatically call the parent class is empty constructor method member variable does not support override writable, no polymorphic effect