Java Exceptions Quiz(Beginner Level)

      No Comments on Java Exceptions Quiz(Beginner Level)

1. Which of the following is a checked exception?

 
 
 
 

2. What happens if a method throws a checked exception but does not declare it in the method signature or handle it?

 
 
 
 

3. Which of the following is a runtime exception?

 
 
 
 

4. Which keyword is used to manually throw an exception in Java?

 
 
 
 

5. What is the output of the following code?


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

 
 
 
 

6. What will happen if an exception is not caught?

 
 
 
 

7. What is the output of this code?

String s = null;
System.out.println(s.length());

 
 
 
 

8. What is the output of this code?

int x = Integer.parseInt("abc");

 
 
 
 

9. What is the output of this code?

try {
int[] arr = new int[3];
System.out.println(arr[5]);
} catch(Exception e) {
System.out.println("Error occurred");
}

 
 
 
 

10. Which of the following is NOT a subclass of RuntimeException?

 
 
 
 


Leave a Reply

Your email address will not be published. Required fields are marked *