Thinking in java Reading Note(8.多态)

1. Overview of Polymorphism  

  Polymorphism separates interface and implementation from another perspective by separating what to do and how to do it . Polymorphism not only improves the organization and readability of code, but also enables the creation of extensible programs -- programs that "grow" both when a project is initially created and as new functionality is needed.

  "Encapsulation" creates new data types by combining characteristics and behaviors . "Implementation hiding" separates the interface from the implementation by "privatizing" the details .

  The role of polymorphism is to eliminate the coupling relationship between types . As we have seen in the previous chapter, inheritance allows an object to be treated as either its own type or its base type. This ability is extremely important because it allows multiple types (derived from the same base class) to be treated as the same type, and the same code can run on these different types without distinction . Polymorphic method calls allow one type to behave differently from other similar types, as long as they are all derived from the same base class . This distinction is manifested in the behavior of the methods, even though the methods can all be called from the same base class .

 

2. Transfer

  method call binding

  

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325065903&siteId=291194637