Which fragment, inserted in the Books interface, enables the code to compile?

Given:

Which fragment, inserted in the Books interface, enables the code to compile?

Given:

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:



Leave a Reply 6

Your email address will not be published. Required fields are marked *


BKhateib

BKhateib

Choice B also work, please all make sure that this question should be which TWO code fragments can be added

BKhateib

BKhateib

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

Fernando

Fernando

The field type must be initializated

l0c

l0c

B doesn’t compile. Correct answer is D.