Home> Java> JavaBase> body text

What is the difference between java interface and abstract class

王林
Release: 2020-05-14 13:15:40
Original
2139 people have browsed it

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!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!