1z0-819 Exam QuestionsBrowse all questions from this exam

1z0-819 Exam - Question 76


Given:

public interface ExampleInterface{ }

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

Show Answer
Correct Answer: AE

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

5 comments
Sign in to comment
StavokOptions: AE
Jun 7, 2023

A & E are correct TESTED

Stavok
Jul 17, 2023

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.

tmuralimanoharOptions: AE
Jun 29, 2023

Answer: AE

d7bb0b2Options: AE
Dec 10, 2023

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

bardemkOptions: BE
Mar 20, 2024

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

ASPushkinOptions: AE
Jul 13, 2024

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