Static inheritance and dynamic inheritance of Java

Source: Internet
Author: User

constructor without return type, otherwise error: The constructor call must is the first.

The static method, which is statically bound, does not need to be overwritten, cannot be overwritten, and is overwritten without static modification.

Inheritance Understanding:

Subclass Child Inherits Parent class father

The child class object is in heap memory, contains the public property inherited from the Father class +public method + own Property + own method,

The declaration of the variable Father f = new children ();

There are several situations to note:

If the attribute methods in the Father class have static or final or private adornments,

Children has a property method of the same name, at which time it is statically bound, unable to implement polymorphism, and heap memory has been statically bound to father by declaration.

F contains only the methods and properties defined in the Father class, which can be dynamically overwritten by the quilt class (excluding static overrides).

Static inheritance and dynamic inheritance of Java

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.