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?
BeginnerAnswers and explanations are in the Veda app.
Q2. What is the superclass of all exceptions in Java?
BeginnerAnswers and explanations are in the Veda app.
Q3. What happens if an exception is not caught in a Java program?
BeginnerAnswers and explanations are in the Veda app.
Q4. Which block is always executed regardless of whether an exception occurs or not?
BeginnerAnswers and explanations are in the Veda app.
Q5. What is the purpose of the `try` block?
BeginnerAnswers and explanations are in the Veda app.
Q6. Which of the following is NOT a type of exception in Java?
BeginnerAnswers and explanations are in the Veda app.
Q7. Which exception is thrown when an array index is out of bounds?
BeginnerAnswers and explanations are in the Veda app.
Q8. What is the purpose of the `getMessage()` method in an exception object?
BeginnerAnswers and explanations are in the Veda app.
Q9. A `finally` block is optional in a try-catch construct.
BeginnerAnswers and explanations are in the Veda app.
Q10. Checked exceptions are checked at runtime.
BeginnerAnswers and explanations are in the Veda app.
Building up · 8 questions
Q11. Which of the following is an unchecked exception?
IntermediateAnswers and explanations are in the Veda app.
Q12. Which of the following correctly declares that a method might throw an IOException?
IntermediateAnswers and explanations are in the Veda app.
Q13. Which of the following is a checked exception?
IntermediateAnswers and explanations are in the Veda app.
Q14. What does the `finally` block ensure?
IntermediateAnswers and explanations are in the Veda app.
Q15. Which class is the parent of `RuntimeException`?
IntermediateAnswers 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"); } ```
IntermediateAnswers and explanations are in the Veda app.
Q17. Which keyword is used to handle multiple exceptions in a single catch block?
IntermediateAnswers and explanations are in the Veda app.
Q18. What is the difference between `throw` and `throws`?
IntermediateAnswers and explanations are in the Veda app.
Topper level · 1 questions
Q19. What happens if a `finally` block contains a `return` statement?
AdvancedAnswers and explanations are in the Veda app.
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