Java Object-oriented polymorphism

Source: Internet
Author: User
Polymorphic:

1 Meaning:

1.1 References of the same type point to different objects are polymorphic that have different implementations-----behavior

1.2 When the same object is shaped into different types, there are different functions--------the polymorphism of the object

2 Up Styling:-----Automatic type conversion

2.1 Super-type references to objects of derived classes

2.2 Types that can be shaped are: Super Class + interface implemented

2.3 Can point out what, see the type of reference

3 Forced type conversion, the success of the condition only the following two kinds:

3.1 The object that the reference is pointing to, which is the type

3.2 The interface is implemented by referencing the object to which it is pointing.

ClassCastException type conversion exception occurs when the 4 strong turns do not meet the above two conditions

Recommendation: Use instanceof to determine if the object you want to refer to is the type before a strong turn

Java Object-oriented 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.