The difference between interfaces and abstract classes:
1. Abstract classes can contain ordinary methods, but interfaces can only contain public and abstract methods (before JDK 1.8) ;
2. There are no access restrictions on member variables in abstract classes, but variables in interfaces can only be modified by public static final;
3. One interface can inherit multiple interfaces, But a class can only have one parent class, and a class can implement multiple interfaces;
4. An abstract class is an abstraction of a type of thing, and an interface is an abstraction of behavior. A class inheriting an abstract class represents the "is it" relationship, while a class implementing an interface represents the "is it having" relationship.
Recommended tutorial:java tutorial
The above is the detailed content of The difference between java abstract class and interface. For more information, please follow other related articles on the PHP Chinese website!