Inheritance of Java Features

Source: Internet
Author: User

Inheriting this feature is an important object-oriented concept, the advantage is to improve the reuse of code, saving development time.

inheritance in Java refers to extending functionality on the basis of a parent class, in which inheritance is divided into subclasses and parent classes.

A class has two important members: member variables and methods.

Java subclasses can obtain member variables and methods of the parent class through the keyword extends. A member of a subclass can have a variable of its own declaration definition, and also inherit from the parent class.

Characteristics of inheritance in Java:

1. Single root inheritance, only one node up, all classes inherit the root node is the Object class.

2.java does not support multiple inheritance. A class cannot inherit multiple classes at the same time * (multi-drink interfaces can be implemented).

3. When a subclass overrides a method of a parent class, the access permission cannot be lower than the parent class.

4. The class overrides the method of the parent class, the runtime system invokes the method implementation of the subclass override, and the subclass object calls the method implementation of the parent class. If you want to use the method of the parent class after overriding, use the keyword super.

Inheritance of Java Features

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.