Java MCQ – Exception Handling – Part 1
This collection of Java Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer focuses on “Exception Handling in Java”.
1. When do exceptions occur in Java code?
A At the time of execution
B At the time of compilation
C Can occur at any time
D None of the above
2. Which of these keywords is not part of exception handling?
A catch
B thrown
C finally
D try
3. Exception is a(n) __________
A Class
B Interface
C Abstract class
D Other
4. In which package in Java, we can find the Exception class?
A java.lang
B java.util
C java.io
D java.awt
5. Exception was introduced in which version of Java?
A Java 1
B Java 2
C Java 3
D Java 4
6. Which of these classes is the highest in the hierarchy in Java?
A java.lang.Exception
B java.lang.Object
C java.lang.Throwable
D java.lang.Error
7. Which of the following keyword is used to explicitly raise an exception?
A raise
B catch
C throw
D throws
8. What is the output of the following code?
public class Main { public static void main(String args[]) { try { System.out.print("Calculate:" + " " + 1 / 0); } catch(ArithmeticException e) { System.out.print("Exception: Division by zero"); } } }
A Calculate:
B Calculate:Exception: Division by zero
C Exception: Division by zero
D Exception: Division by zeroCalculate:
9. Which of the following is a parent class of Error?
A Iterable
B Throwable
C Exception
D throws
10. Which of the following statements is correct?
- The exception is unrecoverable.
- The error is recoverable by debugging.
A 1
B 2
C 1 and 2
D neither 1 nor 2