Thinking in Java Reading Note (8. Polymorphism)

Source: Internet
Author: User

1. Polymorphism Overview

Polymorphism does what and how by separating , separating the interface from the implementation from another angle . Polymorphism not only improves the organization and readability of code, it also creates extensible programs---programs that can "grow" whenever a project is initially created or when new functionality is needed.

  Encapsulation Creates a new data type by merging features and behaviors . "Implementation concealment " separates the interface and implementation by "privatizing" the details.

The role of polymorphism is to eliminate the coupling relationship between types . As we know in the previous chapter, inheritance allows an object to be treated as 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 without distinction on these different types . a polymorphic method call allows a type to exhibit differences from other similar types as long as they are all from the same base class . This distinction is based on the different behavior of the method, although these methods can be called by the same base class .

2. Transfer

Method call Binding

  

  

Thinking in Java Reading Note (8. Polymorphism)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.