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

What should you pay attention to when using inheritance in Java

王林
Release: 2020-07-29 16:46:44
forward
2189 people have browsed it

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template