Only single inheritance between classes and classes
There can be many implementations between the class and the interface;
Multiple inheritance between interface and interface;
|
Statement |
Variable |
Method |
Relationships with interfaces |
Relationships with classes |
Whether the object can be constructed |
Class |
Using the Class keyword declaration, the modifier is public |
Can be declared in any lawful manner |
Can be declared in any lawful manner |
Multi-Implementation |
Single inheritance |
objects can be constructed directly |
Abstract class |
Using the abstract class keyword declaration, the modifier is public |
Can be declared in any lawful manner |
If an abstract class contains abstract methods, then the declaration of this method must be abstract. This method cannot access permissions to private, cannot use the final decoration method, cannot be decorated with static, and the abstract method has no method body. There can be no abstract method in an abstract class |
Multi-Implementation |
Single inheritance |
The object cannot be constructed directly, and if you want to construct it, you must inherit from the subclass and then construct |
Interface |
Using the interface keyword declaration, the modifier is public |
The variables in the interface must be public static final, and this qualification is the default. |
The method declaration in the interface must be public abstract, which is the default. The methods defined in the interface are all abstract methods. |
Multiple inheritance |
Multi-Implementation |
Objects cannot be constructed directly, and if they are to be constructed, they must be implemented by subclasses and then constructed |
The difference between a class, an abstract class, and an interface