Home  >  Article  >  Java  >  What are the differences between java abstraction and interface

What are the differences between java abstraction and interface

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-11-14 11:19:562027browse

What are the differences between java abstraction and interface

When to use abstract classes and interfaces

If you have some methods and want some of them to have Default implementation, then use abstract classes.

If you want to implement multiple inheritance, then you must use interfaces. Since Java does not support multiple inheritance, subclasses cannot inherit multiple classes, but they can implement multiple interfaces. So you can use interfaces to solve it.

If the basic functionality is constantly changing, then you need to use abstract classes. If you keep changing the basic functionality and use an interface, you will need to change all classes that implement the interface.

Difference:

What are the differences between java abstraction and interface

PHP Chinese website, a large number of free Java introductory tutorials, welcome to online learning!

The above is the detailed content of What are the differences between java abstraction and interface. 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
Previous article:How to wrap line in javaNext article:How to wrap line in java