Oracle
1Z0-851 · Question #147
1Z0-851 Question #147: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #147. The question stem and answer options stay visible for context.
Question
Given: 10. interface Foo {} 11. class Alpha implements Foo {} 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args ) { 15. Beta x = new Beta(); 16. //insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?
Options
- AAlpha a = x;
- BFoo f = (Delta)x;
- CFoo f = (Alpha)x;
- DBeta b = (Beta)(Alpha)x;
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.