Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 76

Given:

public interface ExampleInterface{ }

Which two statements are valid to be written in this interface? (Choose two.)

    Correct Answer: A, E

    In a Java interface, it is permissible to declare abstract methods and constants. Abstract methods do not have a body and are meant to be implemented by classes that implement the interface. Therefore, the statements 'public String methodD();' and 'public abstract void methodB();' are valid because they declare abstract methods that do not have a body. Constants in an interface are implicitly public, static, and final, but no such constant is provided in the options. Hence, these two statements are correctly valid in an interface.

Discussion
ASPushkinOptions: AE

answer :AE Interface attributes are by default public, static, final Constants must be set to a value

bardemkOptions: BE

A. Double c = (Double) i; // Inconvertible types; cannot cast 'java.lang.Integer' to 'java.lang.Double B. Double b = Double.valueOf(i); //Ok C. Double a = i; // Required type: Double - Provided: Integer D. double e = Double.parseDouble(i); // Required type: String - Provided: Integer E. double d= i; //Ok

d7bb0b2Options: AE

B is invalid because interface only accepts constant that is marked as static and final

tmuralimanoharOptions: AE

Answer: AE

StavokOptions: AE

A & E are correct TESTED

Stavok

In a Java interface, only abstract methods and constants are allowed. Therefore, the two valid statements that can be written in the ExampleInterface are A. public String methodD(); and E. public abstract void methodB();. Both of these statements declare abstract methods, which is allowed in an interface.