12.
What is the result of the following code snippet?

try {
int num = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception!");
} catch (Exception e) {
System.out.println("Exception!");
}

14.
What is the result of the following code snippet?

try {
String str = null;
System.out.println(str.length());
} catch (NullPointerException e) {
System.out.println("NullPointerException!");
} catch (Exception e) {
System.out.println("Exception!");
}

15.
In Java, can a "finally" block be used without a "try-catch" block?

16.
What is the purpose of the "finally" block in Java exception handling?

17.
In Java, can a "finally" block be used without a "catch" block?

18.
What is the result of the following code snippet?

try {
int[] arr = new int[5];
int value = arr[2];
} catch (NullPointerException e) {
System.out.println("NullPointerException!");
} finally {
System.out.println("Finally Block!");
}

19.
In Java, can a "catch" block catch exceptions of a superclass type?

20.
What is the result of the following code snippet?

try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception!");
} finally {
System.out.println("Finally Block!");
}

Read More Section(Exceptions)

Each Section contains maximum 100 MCQs question on Exceptions. To get more questions visit other sections.