Oracle
1Z0-851 · Question #149
1Z0-851 Question #149: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #149. The question stem and answer options stay visible for context.
Question
Given: 1. public class Test { 2. public enum Dogs {collie, harrier, shepherd}; 3. public static void main(String [] args) { 4. Dogs myDog = Dogs.shepherd; 5. switch (myDog) { 6. case collie: 7. System.out.print("collie "); 8. case default: 9. System.out.print("retriever "); 10. case harrier: 11. System.out.print("harrier "); 12. } 13. } 14.} What is the result?
Options
- Aharrier
- Bshepherd
- Cretriever
- DCompilation fails.
- Eretriever harrier
- FAn exception is thrown at runtime.
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.