The polymorphism of Java

Source: Internet
Author: User

For object-oriented programming languages, polymorphism is the third most basic feature (the first two are data abstraction and inheritance.) ”

"Polymorphism" separates the interface from the concrete implementation details from another angle, i.e., the separation of "what is" and "How to Do" two modules. Using the concept of polymorphism, the organization of code and readability can be improved. In addition, you can create "easy to extend" programs. They can be easily "grown" both during project creation and when new features need to be added.

Encapsulation technology creates new data types by incorporating various features and behaviors. By hiding the details of the implementation, the interface can be separated from the implementation details to make all the details "private" (private). This organization makes it comfortable for those who have programmed programming backgrounds. But polymorphism involves the decomposition of "type". By learning from the previous chapter, you know that by inheriting you can treat an object as its own type or its own base type. This ability is important because multiple types (derived from the same underlying type) can be treated as one of the same types. And with just a piece of code, you can do the same for all the different types. Using a method invocation with polymorphism, one type can separate itself from another similar type, as long as they are derived from the same underlying type. This distinction is achieved through the differences in behavior of various methods, and the invocation of those methods can be implemented through the underlying classes.

In this chapter, you need to learn more about the problem of polymorphism (also called dynamic binding, deferred binding, or run-time binding). At the same time, give some simple examples where all the extraneous parts have been stripped and only the code related to the polymorphism is retained.

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.