Home >Java >JavaBase >What is the difference between java interface and abstract class

What is the difference between java interface and abstract class

王林
王林Original
2020-05-14 13:15:402273browse

What is the difference between java interface and abstract class

The differences are as follows:

1. Abstract classes can have abstract methods or instance methods; all methods in the interface are public abstract methods.

(Video tutorial recommendation: java video)

2. Subclasses use the extends keyword to inherit the abstract class, and subclasses use the implements keyword to implement the interface. Subclasses that implement an interface must override all methods in the interface.

3. Abstract classes can have their own constructors, but interfaces cannot have constructors.

4. A concrete class can only extend one abstract class and can implement multiple interfaces.

Recommended tutorial: java entry program

The above is the detailed content of What is the difference between java interface and abstract class. 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