Given:
and
and
What code inserted into class C would allow it to compile?
Given:
and
and
What code inserted into class C would allow it to compile?
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.
A is correct
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
tested, A
Correct is 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
@Override public void x() { } @Override public void y() { A.super.y(); } @Override public void z() { }
corrected=> A. public void x() { } public void z() { }
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.
That is correct, interface by default is marked as public abstract , so implement acces less restrictive not compile.