In the group, a netizen asked a question about the interface:
Interface I {
Void setvalue (INT Val );
Int getvalue ();
}
Definition:
(A) Class A extends I {
Int value;
Void setvalue (INT Val) {value = val ;}
Int getvalue () {return value ;}
}
Definition B:
(B) interface B extends I {
Void increment ();
}
Definition C:
(C) interface D implements I {
Void increment ();
}
Definition D:
(D) Class E implements I {
Int value;
Public void setvalue (INT Val) {value = val ;}
}
Which of the following statements is correct? Of course, B is the answer first.
In option A, Class A cannot implement interfaces through the extends keyword. Class implementation interfaces must use the implements keyword. A class can implement multiple interfaces at the same time, but only one extends class can be used. Option B is correct. to inherit from another interface, you must use the extends keyword, and you can use extends to implement multiple interfaces at the same time. Option C is incorrect. Option D is obvious, and the interface method is not implemented.
It must be noted that, although the integrated interface uses the extends keyword, it cannot be used to inherit abstract classes in the interface. Multiple Interfaces can be implemented at the same time.