Crazy Java Handout-polymorphic

Source: Internet
Author: User

Parent Class F = new subclass ();

Reference variable F, at compile-time type is the parent class, at run-time type is subclass type. When this reference variable calls the subclass to override that method of the parent class, the actual execution is the overridden method in the subclass. When the method of invoking the variable is run, its method behavior always shows the behavior characteristic of the subclass method, not the behavior characteristic of the parent class method, which may appear: the same type of variable, the same method is called to render a variety of different behavior characteristics, this is polymorphic.

F. Subclass-Unique method, so that although the F reference variable actually contains this method, it is compiled with the parent class type and therefore an error.

Unlike methods, an instance variable of an object does not have a polymorphic f. Variable (the parent class subclass exists), but the output is a variable of the parent class

Coercion type conversions for reference variables

instanceof operator

Crazy Java Handout-polymorphic

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.