Java Exception Handling Quiz - MCQ - Multiple Choice Questions


Exception handling is an important aspect of Java programming that allows you to handle and manage unexpected runtime errors. In this blog post, we present a Java Exception Handling Quiz comprising 10+ multiple-choice questions (MCQ). This quiz aims to assess your understanding of exception handling in Java, including the basics of exceptions, try-catch blocks, and exception propagation. Let's put your knowledge of Java exception handling to the test!.

Learn and Master Java Programming: Learn Java Programming with Examples.

Learn everything about Java 8 features: Java 8 Tutorial and Examples.

Check out 100+ quiz questions: 100+ Quiz Questions to Test Your Java, Spring Boot, Microservices, Hibernate, REST API Skills.

YouTube Video - Java Exception Handling Quiz

Subscribe to my YouTube channel to learn more: https://www.youtube.com/@javaguides.

1. What is an exception in Java?

a) An error that occurs during compilation
b) An unexpected event that occurs during program execution
c) A logical error in the code
d) A warning issued by the compiler

2. Which class is the superclass of all exceptions in Java?

a) Error
b) RuntimeException
c) Throwable
d) Exception

3. Which type of exception is checked at compile-time?

a) RuntimeException
b) Checked Exception
c) Unchecked Exception
d) Error

4. Which keyword is used to handle exceptions in Java?

a) handle
b) try
c) catch
d) throws

5. Which block must follow a try block?

a) final
b) catch
c) done
d) except

6. What does the finally block do in exception handling?

a) Catches the exception
b) Executes only if an exception is thrown
c) Executes code after the try-catch block, regardless of an exception
d) Returns the exception to the caller

7. Which keyword is used to throw an exception explicitly in Java?

a) throw
b) throws
c) try
d) catch

8. Which keyword is used to declare an exception in the method signature?

a) throw
b) throws
c) try
d) catch

9. What type of exception is thrown when a null reference is accessed?

a) NullPointerException
b) IllegalArgumentException
c) ArrayIndexOutOfBoundsException
d) ClassCastException

10. Which of the following is an unchecked exception in Java?

a) IOException
b) SQLException
c) NullPointerException
d) FileNotFoundException

11. Which exception is thrown when an array is accessed with an illegal index?

a) ArrayIndexOutOfBoundsException
b) ClassCastException
c) NullPointerException
d) ArithmeticException

12. Which exception is thrown when an arithmetic operation is attempted to divide by zero?

a) ArithmeticException
b) NumberFormatException
c) ClassCastException
d) NullPointerException

13. Which exception is thrown when an attempt is made to cast an object to a subclass of which it is not an instance?

a) ClassCastException
b) IllegalArgumentException
c) NumberFormatException
d) ArrayStoreException

14. Which exception is thrown by the JVM when it encounters an abnormal condition?

a) Throwable
b) Exception
c) Error
d) RuntimeException

15. Which of the following is a checked exception in Java?

a) IOException
b) ArrayIndexOutOfBoundsException
c) ClassCastException
d) NullPointerException

16. Which keyword is used to create a custom exception in Java?

a) extends
b) implements
c) throws
d) super

17. What happens if an exception is not handled in a program?

a) The program runs normally
b) The program prints an error and continues
c) The program terminates abnormally
d) The program ignores the exception

18. Which exception is thrown when a string cannot be converted to a numeric type?

a) NumberFormatException
b) ClassCastException
c) IllegalArgumentException
d) ArrayIndexOutOfBoundsException

19. Which of the following exceptions is thrown when a file is not found?

a) FileNotFoundException
b) IOException
c) NullPointerException
d) ClassCastException

20. Which of the following is used to group multiple exceptions in a single catch block?

a) Using the | operator
b) Using the & operator
c) Using the && operator
d) Using the || operator

21. Which of the following exceptions is thrown when an application attempts to use a method that is not supported by that object?

a) UnsupportedOperationException
b) ClassCastException
c) NullPointerException
d) ArrayIndexOutOfBoundsException

22. Which of the following is true about the finally block?

a) It is executed only if an exception is thrown
b) It is executed only if an exception is not thrown
c) It is executed whether an exception is thrown or not
d) It is never executed

23. Which exception is thrown by the JVM when the JVM runs out of memory?

a) OutOfMemoryError
b) StackOverflowError
c) ArithmeticException
d) IOException

24. Which exception is thrown when there is an attempt to access a class that does not exist?

a) ClassNotFoundException
b) NoClassDefFoundError
c) ClassCastException
d) FileNotFoundException

25. Which exception is thrown when an input-output operation fails or is interrupted?

a) IOException
b) SQLException
c) NullPointerException
d) FileNotFoundException



Comments

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare