Oracle
1Z0-809 · Question #167
1Z0-809 Question #167: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #167. The question stem and answer options stay visible for context.
Question
Given the code fragment:
public static void main(String[] args) {
ArrayList myList = new ArrayList();
String[] myArray = new String[5];
try {
while (true) {
myList.add("My String");
}
}
catch (RuntimeException re) {
System.out.println("Caught a RuntimeException");
}
catch (Exception ex) {
System.out.println("Caught an Exception");
}
System.out.println("Ready to use");
}
What is the result?
Options
- AThe code fails to compile because a throws keyword is required.
- BExecution terminates in the second catch statement, and Caught an Exception is printed to the console.
- CExecution terminates in the first catch statement, and Caught a RuntimeException is printed to the console.
- DExecution completes normally, and Ready to use is printed to the console.
- EA runtime error is thrown in the thread "main"
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 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.