In the previous article we explored inheritance, in this article we look at polymorphism.
A polymorphic invocation uses the parent class variable to point to the subclass object, the properties and methods that are called are limited to the properties and methods defined in the parent class, and the properties and methods that are specific to the subclass cannot be called. When a polymorphic call is called, the parent class variable points to the subclass object, and if the child class overrides the parent class method, the overriding method of the subclass is called first when the method is called.
Instanceof is used to determine whether the object to which a variable is pointing matches a type, and if the variable is null, the result of the instanceof operation is false.
Polymorphism is mainly manifested in rewriting and overloading, the same behavior of different implementations.
Polymorphism is the main application of polymorphic parameters and polymorphic sets.
The polymorphism of four features of Java object-oriented