General rules for object type conversion, object conversion rules
1. the type of a subclass object can be converted to its parent class, that is, a subclass object can be referenced as a parent class object. This conversion is safe and can be automatically implemented by the Java compiler.
2. the type of a parent class object cannot be converted down to its subclass type, that is, a parent class object cannot be used as a subclass object. However, when the parent class Object references a subclass object, it can be forced type conversion. Otherwise, the compilation can pass, but the exception of ClassCastException will be thrown during runtime.
3. assignment or type conversion cannot be performed between irrelevant classes. That is, the type conversion of a class is limited to two classes with inheritance relationships.
4. Interface polymorphism. The interface cannot be instantiated, but you can declare a reference to the interface. An interface reference can be replaced by an instance object of a specific class that implements an interface. That is, an interface reference can be assigned a value to an object of the class that implements the interface, or an interface reference can be used as a method parameter, use the class object that implements the interface as the real parameter.