From the embodiment of polymorphism ......

Source: Internet
Author: User

Someone in the Forum asked about the embodiment of polymorphism,

Then there is a reply below:

The polymorphism in Java is embodied in two aspects. The first is the polymorphism generated by method overloading, the second is the Runtime polymorphism produced by method overwrite mentioned in the video (parent class references to subclass objects)


Thank you for your reply. Then, I have a reply below:

There are three forms of polymorphism in Java: 1. Method rewriting, 2. Method overloading, 3. Object polymorphism.


Seeing such a neat answer, I almost thought it was a standard answer.

In the spirit of seeking truth and being pragmatic, I opened it silently.

"Bixiangdong Java video tutorial day 02 object-oriented polymorphism (scalability)" video.


At the end of the video, instructor Bi briefly summarized some polymorphism knowledge points:

  1. Embodiment of Polymorphism

    The parent class references its own subclass object.

    The reference of the parent class can also receive its own subclass object.

  2. The premise of Polymorphism

    It must be related to the class. Either inherit or implement.

    There is usually another premise: Overwrite

  3. Benefits of Polymorphism

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

  4. Disadvantages of Polymorphism

    It improves scalability, but can only use the parent class reference to access members in the parent class.


Well, at a glance.

From the embodiment 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.