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

Given:

public interface Builder {

public A build(String str);

}

and

Assuming that this code compiles correctly, which three statements are true? (Choose three.)

    Correct Answer: B, C, E

    Given the provided interface and implementation, certain conditions must hold for the code to compile correctly. First, B must be a subtype of A because the return type of the build method in BuilderImpl must be covariant with the return type of the build method in Builder. Therefore, B is a subtype of A. Second, since you can instantiate B using new B(str), B cannot be abstract, as abstract classes cannot be instantiated. Lastly, A cannot be final because you cannot have a final class be a superclass to another class. Thus, the correct statements are that A cannot be final, B cannot be abstract, and B is a subtype of A.

Discussion
StavokOptions: BCE

The correct answers are B. A cannot be final, C. B cannot be abstract, and E. B is a subtype of A. Since the code compiles correctly, the method build in the BuilderImpl class must be a valid implementation of the method declared in the Question70 interface. This means that the return type of the build method in the BuilderImpl class, which is B, must be a subtype of the return type of the build method in the Builder interface, which is A. Therefore, option E is correct.

Adel2023Options: BCE

correct answer is B,C,E

ASPushkinOptions: BCE

answer: EBC E correct the signature of the implementation method must be the same the return type must be compatible(covariant) between the implementation and interface methods -- B correct because of E -- C correct return new B(str) Abstract classes cannot be instantiated

mendjijetOptions: BCE

BCE are correct

d7bb0b2Options: BCE

B. A cannot be final (So B in impl throw compilation error because B cannot extends A) C. B cannot be abstract (so cannot do new B()). E. B is subclass of A (method is overriding so then => B is A

d7bb0b2Options: BCE

B. A cannot be final. C. B cannot be abstract. E. B is a subtype of A.

Mukes877Options: BCE

correct answer is B,C,E

xuancatOptions: BCF

B, C, F