Reprint https://zhidao.baidu.com/question/39087720.html
Polymorphism: Many forms, derived from biology.
Object-oriented three major features: encapsulation, inheritance, polymorphism. From a certain point of view, encapsulation and inheritance are almost always prepared for polymorphism. This is our last concept, but also the most important point of knowledge.
Polymorphic definition: means that objects of different classes are allowed to respond to the same message. That is, the same message can be used in a variety of different ways depending on the sending object. (Sending a message is a function call)
The technique of implementing polymorphism is called dynamic binding, which is the actual type of the referenced object that is judged during execution, and its corresponding method is called according to its actual type.
The role of polymorphism: to eliminate the coupling relationship between types.
In reality, there are numerous examples of polymorphism. For example, if you press the F1 button, if the current pop-up in the Flash interface is the as 3 help document, if Word Help is currently popping up under Word, Windows Help and Support appears under Windows. The same event occurs on different objects and produces different results.
--------------------------
The last example I think is inappropriate, should say: When you take a bus, you lean on a person's shoulder, if the other side is a man, he may give you a punch, if the other is a beautiful woman, she may give you a palm. Different objects (men or beauties), to the same message (by), make a different response (punch or a palm), this is polymorphic.
Why is there polymorphism in Java?