Here are 10 essential multiple-choice questions on Java Exceptions, covering key concepts.
Question 2
What is the output of the following code?
public class Geeks {
public static void main(String[] args) {
try {
int result = 10 / 0;
System.out.println(result);
} catch (ArithmeticException e) {
System.out.println("Exception caught");
} finally {
System.out.println("Finally block executed");
}
}
}
Question 8
What will happen in the following code?
public class Geeks {
public static void main(String[] args) {
try {
throw new NullPointerException("Demo");
} catch (ArithmeticException e) {
System.out.println("Arithmetic Exception");
} finally {
System.out.println("Finally block executed");
}
}
}
There are 10 questions to complete.
Quiz about Java Exceptions