About inheritance __java in Java

Source: Internet
Author: User

First, open the question and tell the knowledge points clearly.

1. If the subclass inherits the attribute, then the subclass will copy a copy from the parent class, and the value is exactly the same, that is, it has its own property in the object and is exactly the same as the parent class

2. If the subclass inherits the method, then the subclass does not get exactly the same in the parent class, but when it is called, it goes to the parent object to find the inherited method and then executes it and why it can be found. Because their memory address is next to each other.

As shown in the following figure


The inherited method of this presentation (output is 10 instead of-990)



The following illustration shows the inheritance properties





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.