Oracle
1Z0-819 · Question #189
1Z0-819 Question #189: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #189. The question stem and answer options stay visible for context.
Question
public class X {
protected void print(Object obj) {
print(objects);
}
public final void print(Object... objects) {
collection.forEach(System.out::println);
}
}
public class Y extends X {
public void print(Object obj) {
System.out.println("obj " + obj);
}
public void print(Object... objects) {
for (Object object : objects) {
System.out.println("[" + object + "]");
}
}
public void print(Collection collection) {
print(collection.toArray());
}
}
Why does this compilation fail?Options
- AThe method X.print(Object) does not call the method super.print(Object)
- BThe method X.print(Object...) is not accessible to Y
- CThe method Y.print (collection), however. Out of scope, is an invalid Java identifier.
- DThe method print (Object) and the method print (Object...) are duplicates of each other. The method X.print (Object...) cannot override the final method X.print (Object...)
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.