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