Key to inheritance in Java

Source: Internet
Author: User

One of the major features of Java is that it inherits.

1. Because a subclass inherits a parent class, it has a later polymorphism.

2. Class inheritance, not to save code, inheritance for inheritance, and that no related classes linked together, inheritance must be used in is a, for example, students in the large category of people, cats in the big category of cats.

3. The inheritance of class greatly improves the reusability of code and saves the code. It also facilitates post-code maintenance.

4. When a subclass inherits from a parent class, the child class cannot inherit the call if it has a member or method that is decorated by private in the parent class.

5, in multi-layer inheritance, the lowest subclass inherits all the members and methods that all of the parent classes can inherit.

6. In Java, multiple inheritance is not supported, because when a subclass invokes a member or method inside a parent class, the same member or method appears in the parent class, and the child class cannot know which member or method of the parent class is called.

7. Although multiple inheritance is not supported in Java, it is still retained because it is possible to implement " multiple implementations " in other ways, i.e. interfaces (not yet self-taught).

Key to inheritance in 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.