Differences between abstract classes and interfaces
I recently reviewed some basic Java knowledge. Here I will summarize the differences between abstract classes and interfaces.
1. abstract class represents an inheritance relationship in Java. A class can only use an inheritance relationship once. However, a class can implement multiple interfaces.
2. abstract class can have its own data members or non-abstarct member methods. In interface, only static data members that cannot be modified (that is, they must be static final, but data members are not defined in interfaces) are allowed. All member methods are abstract.
3. If a subclass implements an interface, all methods in the interface must be implemented (whether or not required); if it inherits an abstract class, you only need to implement the required methods.
4. abstract class is a base class and cannot be instantiated. interfaces are declarations. each class of the corresponding interface must implement methods.