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

Given:

Which two changes need to be made to make this class compile? (Choose two.)

    Correct Answer: B, E

    The provided code attempts to define an interface that includes a non-abstract method, `isValueANumber`. However, interfaces in Java cannot contain non-abstract methods unless they are given default or static implementations. Thus, to make this code compile, you need to change the declaration of `API` from an interface to an abstract class, which allows both abstract and concrete methods. Additionally, the `checkValue` method in its current form, being abstract in nature, must be explicitly declared as abstract. This solidifies the changes required: changing `API` to an abstract class `public abstract class API`, and declaring the `checkValue` method as abstract `public abstract void checkValue(Object value) throws IllegalArgumentException;`. These changes ensure that the class contains both abstract and concrete methods, compliant with Java's syntax rules.

Discussion
ASPushkinOptions: BE

answer: EB The second method (isValueANumber) cannot be changed and it is a full method. This implies the need for a class in the header (A or E) If the header is E (public abstract class API), then the first method (checkValue) must be abstract or a full (with body). There is just abstract case (B). For the case A the first method (checkValue) must be a full (with body). There is no such a possibility.

d7bb0b2Options: BE

NEED TWO OPTIONS FOR COMPILATION

dillemanOptions: BE

B and E, tested

StavokOptions: BE

B AND E ARE CORRECT,TESTED