From the manifestation of polymorphism ...

Source: Internet
Author: User

In the forum, there are questions about the manifestation of polymorphism,

And then there's a reply:

In Java, the polymorphism is embodied in two aspects, the first is the method overload generated by the compile-time polymorphism, the second is the video is covered by the method of the cover produced by the runtime polymorphism (parent class reference to child class object)


Landlord reply Thank you, and then there is a reply:

There are three forms of polymorphism in Java: 1, method of replication, 2, overloading of methods 3, polymorphism of objects


See so neat answer, almost thought it was the standard answer.

In a pragmatic spirit, I silently opened the

"Bi Xiangdong Java video Eighth day 02 object-oriented polymorphism (extensibility)" this video.


At the end of the video, Mr. Bi simply summed up some of the polymorphic knowledge Points:

  1. The manifestation of polymorphism

    The parent class reference points to its own subclass object

    A reference to a parent class can also receive its own child class object

  2. The premise of polymorphism

    Must be a relationship between a class and a class. Either inherit, or implement.

    There is usually a premise: there is an overlay

  3. The benefits of polymorphism

    The appearance of polymorphism greatly improves the expansibility of the program.

  4. The drawbacks of polymorphism

    Extensibility is improved, but members in the parent class can only be accessed with the parent class reference.


Well, at a glance.

From the manifestation of 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.