Home  >  Article  >  Java  >  What should you pay attention to when using inheritance in Java

What should you pay attention to when using inheritance in Java

王林
王林forward
2020-07-29 16:46:442012browse

What should you pay attention to when using inheritance in Java

Notes on the use of inheritance:

(Recommended tutorial: java introductory tutorial)

1. The parent class is also called Super class, base class. Subclass: Derived class, etc.

3. There is only single inheritance in Java, and there is no multiple inheritance like C. Multiple inheritance can cause confusion, make the inheritance chain too complex, and make the system difficult to maintain.

3. There is no multiple inheritance for classes in Java, but there is multiple inheritance for interfaces.

(Video tutorial recommendation: java video tutorial)

4. The subclass inherits the parent class and can obtain all the properties and methods of the parent class (except for the structure of the parent class) method), but may not necessarily be directly accessible (for example, the properties and methods private to the parent class).

5. If extends is not called when defining a class, its parent class is: java.lang.Object.

The above is the detailed content of What should you pay attention to when using inheritance in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete