Which fragment, inserted in the Books interface, enables the code to compile?
A.
public abstract String type;
public abstract String getType();
B.
public static String type;
public abstract String getType();
C.
public String type = “Fiction”;
public static String getType();
D.
public String type = “Fiction”;
public abstract String getType();
Explanation:
Choice B also work, please all make sure that this question should be which TWO code fragments can be added
for the interface field Books.type; only public, static & final are permitted
for the interface method only public & abstract are permitted
Source Java 7 Documentation
The field type must be initializated
B doesn’t compile. Correct answer is D.
+1
D