Exceptions Questions and Answers

Take Exam

Exception handling in Java is one of the most frequently tested concepts in both academic exams and software placement tests. This compilation of Exceptions in Java programming questions with answers covers topics such as try-catch blocks, finally statements, custom exceptions, and exception hierarchies. Designed for TCS, Wipro, and Infosys aspirants, these Java MCQs and explanations ensure you master the art of writing reliable and error-handling Java programs. Practicing these questions will help you confidently approach real-world coding scenarios and interview challenges.

Exceptions

Showing 10 of 30 questions

11. Which of these is a checked exception in Java?

  • RuntimeException
  • IOException
  • NullPointerException
  • ArithmeticException
Show Answer Report

12. What is the parent class of all exceptions in Java?

  • Throwable
  • Exception
  • Error
  • Object
Show Answer Report

13. Which keyword is used to explicitly throw an exception?

  • throws
  • throw
  • try
  • catch
Show Answer Report

14. Which block is used to handle exceptions in Java?

  • try-catch
  • throw-catch
  • exception-handle
  • error-handle
Show Answer Report

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

  • finally
  • catch
  • throw
  • throws
Show Answer Report

16. What is the output when a NullPointerException occurs?

  • Runtime exception when using null object reference
  • Compile time error
  • Warning message
  • No output
Show Answer Report

17. Which of these exceptions is related to array operations?

  • ArrayIndexOutOfBoundsException
  • NullPointerException
  • ClassCastException
  • IOException
Show Answer Report

18. What does the try-with-resources statement ensure?

  • Automatic resource closure
  • Manual resource management
  • Exception suppression
  • No exception handling
Show Answer Report

19. Which exception occurs when converting invalid string to number?

  • NumberFormatException
  • IllegalArgumentException
  • ParseException
  • FormatException
Show Answer Report

20. What is the purpose of the throws keyword?

  • Declare exceptions in method signature
  • Throw an exception
  • Catch an exception
  • Handle an exception
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test