Exceptions Questions and Answers
Practice ModeShowing 10 of 30 questions
Q11
Which of these is a checked exception in Java?
Answer: Option B
Explanation: Checked exceptions must be handled at compile time.
Q12
What is the parent class of all exceptions in Java?
Answer: Option A
Explanation: Throwable is the superclass of all errors and exceptions.
Q13
Which keyword is used to explicitly throw an exception?
Answer: Option B
Explanation: The throw keyword is used to manually throw exceptions.
Q14
Which block is used to handle exceptions in Java?
Answer: Option A
Explanation: try-catch blocks are used for exception handling.
Q15
Which block is always executed regardless of whether an exception occurs or not?
Answer: Option A
Explanation: finally block always executes after try-catch.
Q16
What is the output when a NullPointerException occurs?
Answer: Option A
Explanation: NullPointerException occurs when using null objects.
Q17
Which of these exceptions is related to array operations?
Answer: Option A
Explanation: ArrayIndexOutOfBoundsException occurs with invalid array indices.
Q18
What does the try-with-resources statement ensure?
Answer: Option A
Explanation: try-with-resources automatically closes resources.
Q19
Which exception occurs when converting invalid string to number?
Answer: Option A
Explanation: NumberFormatException occurs during invalid number conversion.
Q20
What is the purpose of the throws keyword?
Answer: Option A
Explanation: throws declares exceptions that a method might throw.