Question 1 of 25
Hints left: 3
Q1
In Java, which type of exceptions are unchecked at compile-time?
Q2
In Java, can a "finally" block be used without a "catch" block?
Q3
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!"); }
Q4
In Java, can a "catch" block catch multiple exceptions?
Q5
In Java, can a "finally" block be used without a "try-catch" block?
Q6
In Java, can a method declare "throws" for a checked exception that is not thrown in the method body?
Q7
What is the purpose of the "try" block in exception handling?
Q8
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!"); }
Q9
In Java, can a method throw any checked exception without declaring it using "throws"?
Q10
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!"); }
Q11
What is an exception in Java?
Q12
What is the purpose of the "finally" block in Java exception handling?
Q13
What will be the output of the following Java code? class A { public int i; public int j; A() { i = 1; j = 2; } } class B extends A { int a; B() { super(); } } class super_use { public static void main(String args[]) { B obj = new B(); System.out.println(obj.i + " " + obj.j) } }
Q14
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!"); }
Q15
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!"); }
Q16
What is the purpose of the "catch" block in exception handling?
Q17
In Java, which type of exceptions are checked at compile-time?
Q18
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!"); }
Q19
Which keyword is used to handle exceptions in Java?
Q20
In Java, can a method declare multiple exceptions using the "throws" keyword?
Q21
What is the purpose of the "throw" keyword in Java exception handling?
Q22
In Java, can a method declare both "throws" and "throw" statements?
Q23
In Java, can a "catch" block catch exceptions of a superclass type?
Q24
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!"); }
Q25
What is the purpose of the "throws" keyword in Java method declaration?