The polymorphism of four features of Java object-oriented

Source: Internet
Author: User

In the previous article we explored inheritance, in this article we look at polymorphism.

A polymorphic invocation uses the parent class variable to point to the subclass object, the properties and methods that are called are limited to the properties and methods defined in the parent class, and the properties and methods that are specific to the subclass cannot be called. When a polymorphic call is called, the parent class variable points to the subclass object, and if the child class overrides the parent class method, the overriding method of the subclass is called first when the method is called.

Instanceof is used to determine whether the object to which a variable is pointing matches a type, and if the variable is null, the result of the instanceof operation is false.

Polymorphism is mainly manifested in rewriting and overloading, the same behavior of different implementations.

Polymorphism is the main application of polymorphic parameters and polymorphic sets.

The polymorphism of four features of Java object-oriented

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.