21.
In Java, can a method declare both "throws" and "throw" statements?

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

try {
String str = "Java";
int num = Integer.parseInt(str);
} catch (NumberFormatException e) {
System.out.println("NumberFormatException!");
} catch (Exception e) {
System.out.println("Exception!");
} finally {
System.out.println("Finally Block!");
}

23.
In Java, can a method declare "throws" for a checked exception that is not thrown in the method body?

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

try {
throw new NullPointerException();
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception!");
} catch (NullPointerException e) {
System.out.println("NullPointerException!");
}

25.
In Java, can a "finally" block have a "return" statement?

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

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

27.
In Java, can a "try" block have multiple "catch" blocks?

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

try {
throw new ArithmeticException();
} catch (Exception e) {
System.out.println("Exception!");
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception!");
}

29.
In Java, can a "catch" block catch exceptions of a subclass type before catching exceptions of a superclass type?

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

try {
throw new RuntimeException();
} catch (RuntimeException e) {
System.out.println("Runtime Exception!");
} catch (Exception e) {
System.out.println("Exception!");
}

Read More Section(Exceptions)

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