Exceptions Questions and Answers

Practice Mode
Showing 10 of 30 questions
Q21
Which of these is NOT a checked exception?
  • A NullPointerException
  • B IOException
  • C SQLException
  • D ClassNotFoundException
Answer: Option A
Explanation: RuntimeException and its subclasses are unchecked.
Q22
What happens if an exception is not caught?
  • A Program terminates if reaches main method
  • B Program continues normally
  • C Exception is ignored
  • D Automatic recovery
Answer: Option A
Explanation: Uncaught exceptions propagate up the call stack.
Q23
Which method returns the description of an exception?
  • A getMessage()
  • B toString()
  • C printStackTrace()
  • D getDescription()
Answer: Option A
Explanation: getMessage() provides exception details.
Q24
What is the difference between error and exception?
  • A Errors are unrecoverable, exceptions can be handled
  • B Exceptions are unrecoverable, errors can be handled
  • C Both are same
  • D Errors are checked, exceptions are unchecked
Answer: Option A
Explanation: Errors are serious system problems, exceptions are application issues.
Q25
Which exception occurs when a file is not found?
  • A FileNotFoundException
  • B IOException
  • C FileException
  • D NoFileException
Answer: Option A
Explanation: FileNotFoundException is a checked exception for missing files.
Q26
What is exception propagation in Java?
  • A Exception moves up call stack until caught
  • B Exception moves down call stack
  • C Exception is automatically handled
  • D Exception is ignored
Answer: Option A
Explanation: Exceptions move up the call stack until caught.
Q27
Which class is used to create custom exceptions?
  • A By extending Exception class
  • B By implementing Exception interface
  • C By using new keyword
  • D By using createException method
Answer: Option A
Explanation: Extend Exception class to create custom exceptions.
Q28
What is the purpose of the printStackTrace() method?
  • A Prints exception stack trace
  • B Handles the exception
  • C Prevents exception
  • D Ignores exception
Answer: Option A
Explanation: Prints the stack trace to help debug exceptions.
Q29
Which exception occurs during arithmetic operations?
  • A ArithmeticException
  • B MathException
  • C CalculationException
  • D NumberException
Answer: Option A
Explanation: ArithmeticException for math errors like division by zero.
Q30
What is the main advantage of exception handling?
  • A Maintains normal program flow
  • B Increases program speed
  • C Reduces code size
  • D Eliminates all errors
Answer: Option A
Explanation: Prevents program termination and maintains normal flow.
Questions and Answers for Competitive Exams Various Entrance Test