Execution-time polymorphism is one of the most powerful mechanisms for object-oriented programming code reuse. The concept of Java polymorphism can also be said to be "an interface." Multiple methods ". Java implementation-time polymorphism is based on dynamic method scheduling, which is a mechanism to call overloaded methods at execution time, rather than at compile times.
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. Overloaded overloading is a representation of polymorphism in a class. Suppose you define a method in a subclass that has the same name and parameters as its parent class. We say that the method is rewritten (overriding).
When an object of a subclass uses this method, the definition in the subclass is called. For it. The definition in the parent class is "masked".
Assume that multiple methods with the same name are defined in a class, either with different number of parameters or with different parameter types, which are called overloads of the Method (overloading).
The overloaded method is the ability to change the type of the return value. 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. Suppose you define a method in a subclass that has the same name and parameters as its parent class. We say that the method is rewritten (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".
Assume that multiple methods with the same name are defined in a class. They may have a different number of parameters or have different parameter types. is called a method's overload (overloading). The overloaded method is the ability 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. (but assuming that the superclass is forced to be converted to subclasses, it is possible to invoke methods that are newly added in the subclass and that the superclass does not.)
)
[Java interview] understanding of polymorphism