Java Exceptions: 19 MCQs

All 19 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 10 questions

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

Beginner
A try
B catch
C throws
D throw

Answers and explanations are in the Veda app.

Q2. What is the superclass of all exceptions in Java?

Beginner
A Throwable
B Error
C Exception
D RuntimeException

Answers and explanations are in the Veda app.

Q3. What happens if an exception is not caught in a Java program?

Beginner
A The exception is ignored
B The program continues normally
C The program restarts
D The program terminates abruptly

Answers and explanations are in the Veda app.

Q4. Which block is always executed regardless of whether an exception occurs or not?

Beginner
A catch
B finally
C try
D throw

Answers and explanations are in the Veda app.

Q5. What is the purpose of the `try` block?

Beginner
A To enclose code that might throw an exception
B To always execute code
C To handle exceptions
D To declare exceptions

Answers and explanations are in the Veda app.

Q6. Which of the following is NOT a type of exception in Java?

Beginner
A Checked exception
B Unchecked exception
C Runtime exception
D Compile-time exception

Answers and explanations are in the Veda app.

Q7. Which exception is thrown when an array index is out of bounds?

Beginner
A IndexOutOfBoundsException
B IllegalArgumentException
C ArrayStoreException
D ArrayIndexOutOfBoundsException

Answers and explanations are in the Veda app.

Q8. What is the purpose of the `getMessage()` method in an exception object?

Beginner
A To print the stack trace
B To return a detailed message about the exception
C To rethrow the exception
D To suppress the exception

Answers and explanations are in the Veda app.

Q9. A `finally` block is optional in a try-catch construct.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q10. Checked exceptions are checked at runtime.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Building up · 8 questions

Q11. Which of the following is an unchecked exception?

Intermediate
A ArithmeticException
B SQLException
C ClassNotFoundException
D IOException

Answers and explanations are in the Veda app.

Q12. Which of the following correctly declares that a method might throw an IOException?

Intermediate
A public void readFile() throws IOException
B public void readFile() catch IOException
C public void readFile() throw IOException
D public void readFile() finally IOException

Answers and explanations are in the Veda app.

Q13. Which of the following is a checked exception?

Intermediate
A ArrayIndexOutOfBoundsException
B FileNotFoundException
C ArithmeticException
D NullPointerException

Answers and explanations are in the Veda app.

Q14. What does the `finally` block ensure?

Intermediate
A That exceptions are caught
B That the program ends normally
C That no exception is thrown
D That cleanup code runs

Answers and explanations are in the Veda app.

Q15. Which class is the parent of `RuntimeException`?

Intermediate
A Exception
B Object
C Throwable
D Error

Answers and explanations are in the Veda app.

Q16. What is the output of the following code? ```java try { int x = 10 / 0; } catch (ArithmeticException e) { System.out.println("Caught"); } finally { System.out.println("Finally"); } ```

Intermediate
A Caught
B Compilation error
C Finally
D Caught Finally

Answers and explanations are in the Veda app.

Q17. Which keyword is used to handle multiple exceptions in a single catch block?

Intermediate
A ||
B &&
C &
D |

Answers and explanations are in the Veda app.

Q18. What is the difference between `throw` and `throws`?

Intermediate
A `throw` is used to throw an exception, `throws` declares exceptions in a method signature
B `throw` is used in a method body, `throws` is used in a catch block
C `throw` is for checked exceptions, `throws` is for unchecked
D There is no difference

Answers and explanations are in the Veda app.

Topper level · 1 questions

Q19. What happens if a `finally` block contains a `return` statement?

Advanced
A The program throws an exception
B The return value from the try block is used
C The return value from the finally block overrides the try block's return
D A compilation error occurs

Answers and explanations are in the Veda app.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free to start, in more than 40 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Paper Solver

Get Veda free See what students get

Free to start · Android app and web · More than 40 languages