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

Given:

interface Books {

//insert code here

}

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

Given:

interface Books {

//insert code here

}

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

A.
public abstract String type;
public abstract String getType();

B.
public staticString type;
public abstract String getType();

C.
public String type = “Fiction”;
public static String getType();

D.
public String type = “Fiction”;
public abstract String getType();



Leave a Reply 4

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


Charlie

Charlie

The field in a interfact defaults to public static final.

Naresh

Naresh

Correct Answer D

Bahaa Khateib

Bahaa Khateib

D is the correct answer for sure

Shamitha Silva

Shamitha Silva

fields need both be final and static , without static we cannot initialize, because we have no constructors in interfaces.

And methods are public abstract , and cannot be static because interface methods are designed solely for instance specific. without an implementation they are useless.