Home  >  Article  >  Java  >  Can a java class have multiple parent classes?

Can a java class have multiple parent classes?

烟雨青岚
烟雨青岚Original
2020-07-03 09:39:0012654browse

A java class cannot have multiple parent classes, but only one parent class. Java classes only support single inheritance and do not support multiple inheritance, so they can only have one parent class; interfaces can have multiple inheritance, so interfaces can have multiple parent classes.

Can a java class have multiple parent classes?

Java classes can only have one parent class

Java classes only support single inheritance and do not support multiple inheritance . In other words, there can only be one parent class.

But interfaces can be inherited from multiple sources. Interfaces can have multiple parent classes.

The meaning of parent class in Java is:

If a certain class B inherits class A, then A is the parent class of B. After inheritance, B owns all public methods and properties of A.

Java is an object-oriented programming language. It not only absorbs the various advantages of the C language, but also abandons the concepts such as multiple inheritance and pointers that are difficult to understand in C. Therefore, the Java language is powerful and easy to use. Two characteristics. As a representative of static object-oriented programming languages, Java language perfectly implements object-oriented theory and allows programmers to perform complex programming with an elegant way of thinking.

Java has the characteristics of simplicity, object-oriented, distributed, robustness, security, platform independence and portability, multi-threading, and dynamics. Java can write desktop applications, Web applications, distributed systems and embedded system applications, etc.

Recommended tutorial: "java tutorial"

The above is the detailed content of Can a java class have multiple parent classes?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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