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