Which of the following statements about interfaces is false? ()

Which of the following statements about interfaces is false? ()
A. An interface can only contain abstract methods and constants

B. A class can implement multiple interfaces

C. When a class implements an interface, it must implement its methods

D. Interfaces cannot be inherited
 
Choose the wrong one. Answer: D
A interface can only contain abstract methods and constants
. This is correct.
Let me tell you the difference between abstract classes and interfaces: abstract classes are modified by the abstract keyword, and interfaces are modified by the interface keyword. In addition to abstract methods, abstract classes can also have data members and non-abstract methods; while all methods in an interface must be abstract, and data members can also be defined in an interface, but they must be constants.
B A class can implement multiple interfaces
. This is correct. Java supports multiple implementations but does not support multiple inheritance
. C. Classes must implement methods when implementing interfaces.
This is correct. It is said in the official documentation of the interface. A class implementing an interface must implement all of its methods.
The statement that the D interface cannot be inherited
is false. Interfaces can be inherited by interfaces. You can try it in the java editor. An interface can inherit multiple interfaces
interface C extends A, B {} is OK.
A class can implement multiple interfaces:
class D implements A,B,C{}
but a class can only inherit one class, not multiple A class
class B extends A{}
can also implement an interface while inheriting a class:
class E extends D implements A,B,C{}
This is why an interface is chosen instead of an abstract class
 
A class can only inherit (extends) one class (class) and can implement (implements) multiple interfaces (Interface).
An interface can only extend an interface;
 
 
 
 
 Which of the following about the error in the interface is ()
 a. The data in the interface must set the initial value
 b. The general method cannot be declared in the interface
 c. References can be declared in interfaces
 d. All of the above are correct
 
 
 
 
 
 
The answer is: C
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326542879&siteId=291194637