Oracle
1Z0-851 · Question #71
1Z0-851 Question #71: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #71. The question stem and answer options stay visible for context.
Question
Given: interface A { void x(); } class B implements A { public void x() {} public void y() {} } class C extends B { public void x() {} } and: 20. java.util.List<A> list = new java.util.ArrayList<A>(); 21. list.add(new B()); 22. list.add(new C()); 23. for (A a : list) { 24. a.x(); 25. a.y(); 26. } What is the result?
Options
- AThe code runs with no output.
- BAn exception is thrown at runtime.
- CCompilation fails because of an error in line 20.
- DCompilation fails because of an error in line 21.
- ECompilation fails because of an error in line 23.
- FCompilation fails because of an error in line 25.
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 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.