Three characteristics of object-oriented [polymorphism]

 

Polymorphism refers to the same method call, due to the different objects may have different behavior. In real life, the same method, specific implementation will be completely different.
For example: The same method is "rest" of calling people, sleep is Joe Smith, John Doe is tourism, knocking the code programmers, math professor is to do the math;
   the same is "eating" method call people, Chinese people use chopsticks, the British eat with knife and fork, Indians eat with their hands.

 

Polymorphism points:

  1. Polymorphic method is polymorphic, the polymorphism is not a property (attribute independent and polymorphism).

  2. The presence of polymorphism have three necessary conditions: inherited, override methods, references to the parent class subclasses the object.

  3. After the parent class reference to sub-class object, method calls with reference to a subclass overrides the superclass, then multi-state arises.

Guess you like

Origin www.cnblogs.com/sdrbg/p/11221848.html