There are two kinds of polymorphism in JAVA: runtime polymorphism and compile-time polymorphism. Polymorphism is one of the core characteristics of object-oriented, and the polymorphism of a class provides flexibility in the design of members in the class and diversity in the execution of methods.
Polymorphism refers to allowing objects of different classes to respond to the same message. In other words, the same message can adopt many different behaviors according to the different sending objects. (The message sent is a function call)
The technology of realizing polymorphism is called dynamic binding, which is to judge the actual type of the referenced object during execution and call its corresponding method according to its actual type.
Extended data:
Benefits of polymorphism:
1, the alternative polymorphism can replace the existing code. For example, polymorphism applies to the Circle class, and also to any other circular geometry, such as rings.
2. Extensibility polymorphism can be extended to code. Adding new subclasses does not affect the polymorphism, inheritance and other characteristics of existing classes. In fact, it is easier to get polymorphic functions by adding subclasses.
3. Interface capability polymorphism is realized by superclass signing a method and providing subclasses with a * * * interface, which is perfected or covered by subclasses.
4, flexibility (flexibility) It embodies the flexible and diverse operations in the application, and improves the use efficiency.
5. Simple polymorphism simplification is particularly prominent and important for the coding and modification process of application software, especially when dealing with the operation and operation of a large number of objects.
Reference: Baidu Encyclopedia-Polymorphism