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

Given:

and

and

What code inserted into class C would allow it to compile?

    Correct Answer: A

    Class C must implement all abstract methods from both interface A and abstract class B. Therefore, it must provide public implementations for the abstract method 'x' from interface A and the abstract method 'z' from class B. Option A does this by including public methods for both 'x()' and 'z()'. Other options have issues such as inappropriate access levels or misunderstandings about overriding rules, making Option A the correct answer.

Discussion
StavokOption: A

A is correct

ASPushkinOption: A

answer: A B Failed default method y() is a public so it can not has a weaker access privileges with the inheritance --------- CDE FAILED interface method x() is a public it can not has a weaker access privileges with the inheritance

OmnisumemOption: A

tested, A

mendjijetOption: A

Correct is A

d7bb0b2Option: A

A =>is correct , B=> Cannot user super.y() to call interface method , this is only used to call superclass methods not interface method, so if you call default method of interface directly use y(); C=> void x() is less restrictive that method in interface, the interface methhos is marked as public abstract. D=> SAME REASON B + C E=> SAMME REASON C

JticOption: C

@Override public void x() { } @Override public void y() { A.super.y(); } @Override public void z() { }

Jtic

corrected=> A. public void x() { } public void z() { }

[Removed]

C Will not work as the answer C states: void x(){} which is package private. And an overriding method needs wider or the same access modifiers.

d7bb0b2

That is correct, interface by default is marked as public abstract , so implement acces less restrictive not compile.