Run-time polymorphism
Runtime polymorphism is one of the most powerful mechanisms for object-oriented programming code reuse, and the concept of Java polymorphism can also be said to be "one interface, multiple methods". Java's implementation of runtime polymorphism is based on dynamic method scheduling, which is a mechanism for calling overloaded methods at runtime rather than at compile time.
The overridden overriding and overloaded overloading of a method are different manifestations of Java polymorphism. Overriding overriding is a representation of polymorphism between a parent class and a subclass, and overloading overloading is a representation of polymorphism in a class.
If you define a method in a subclass that has the same name and arguments as its parent class, we say that the method is overridden (overriding).
When an object of a subclass uses this method, the definition in the subclass is called, and for it the definition in the parent class is "masked". If more than one method with the same name is defined in a class, they either have a different number of arguments or have different parameter types, which is called a method overload (overloading).
Multi-state implementation overloading and rewriting
The overridden overriding and overloaded overloading of a method are different manifestations of Java polymorphism. Overriding overriding is a representation of polymorphism between a parent class and a subclass, and overloading overloading is a representation of Java polymorphism in a class.
If you define a method in a subclass that has the same name and arguments as its parent class, we say that the method is overridden (overriding). When an object of a subclass uses this method, the definition in the subclass is called, and for it the definition in the parent class is "masked".
If more than one method with the same name is defined in a class, they either have a different number of arguments or have different parameter types, which is called a method overload (overloading). The overloaded method is to change the type of the return value.
When a Superclass object reference variable refers to a subclass object, the type of the referenced object rather than the type of the reference variable determines which member method to call, but the method that is called must be defined in the superclass, that is, the method covered by the quilt class.
(However, if you force a superclass to be converted to subclasses, you can call methods that are newly added in the subclass and that are not available in the superclass.) )
Java polymorphism in class, parent-child performance