The number of inheritance between classes and classes, classes and interfaces, and interfaces.
1. Classes and classes can be represented as inheritance relationships, expressed by the extends keyword. This is because if A class inherits Class A and Class B, if AB has two similar methods, it cannot determine which method to inherit, therefore, class inheritance can only be one-to-one. However, a class can have multiple subclasses,A class can have only one parent class.
2. The relationship between classes and interfaces can be expressed as an implementation relationship, expressed by the implements keyword. A class can implement multiple interfaces. Because methods in interfaces are abstract methods,
Only the form has no specific implementation, which is implemented in the class.
3. An interface and an interface can be represented as an inherited relationship. An interface is represented by the extends keyword. An interface can inherit multiple interfaces.
Relationship between interfaces and Classes
The interface is not a class, because the keywords are different!
Class
Interface
Only the method itself is defined in the interface, but the implementation process of the method is not defined.
Class is the carrier of interface implementation, that is, the method defined in the class implementation interface, is actually the implementation process of defining methods.
In java, how can I write a class that inherits a class and implements an interface at the same time?
Class AClass extends BClass implements CInterface
{
...
}