Podcast
Questions and Answers
Which of the following is NOT a checked exception in Java?
Which of the following is NOT a checked exception in Java?
- RuntimeException (correct)
- ClassNotFoundException
- SQLException
- IOException
What will be the output of the following code snippet?
try {
int[] arr = new int[5];
System.out.println(arr[10]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Array index out of bounds!");
}
What will be the output of the following code snippet?
try { int[] arr = new int[5]; System.out.println(arr[10]); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Array index out of bounds!"); }
- 0
- Array index out of bounds! (correct)
- 10
- Compiler error
Which of the following statements about exception handling in Java is correct?
Which of the following statements about exception handling in Java is correct?
- The try block must always be followed by a catch or finally block.
- The catch block can handle multiple types of exceptions. (correct)
- The finally block is optional and can be omitted.
- The throw keyword is used to create a new exception object.