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

21. Which of these is NOT a checked exception?

  • NullPointerException
  • IOException
  • SQLException
  • ClassNotFoundException
Show Answer Report

22. What happens if an exception is not caught?

  • Program terminates if reaches main method
  • Program continues normally
  • Exception is ignored
  • Automatic recovery
Show Answer Report

23. Which method returns the description of an exception?

  • getMessage()
  • toString()
  • printStackTrace()
  • getDescription()
Show Answer Report

24. What is the difference between error and exception?

  • Errors are unrecoverable, exceptions can be handled
  • Exceptions are unrecoverable, errors can be handled
  • Both are same
  • Errors are checked, exceptions are unchecked
Show Answer Report

25. Which exception occurs when a file is not found?

  • FileNotFoundException
  • IOException
  • FileException
  • NoFileException
Show Answer Report

26. What is exception propagation in Java?

  • Exception moves up call stack until caught
  • Exception moves down call stack
  • Exception is automatically handled
  • Exception is ignored
Show Answer Report

27. Which class is used to create custom exceptions?

  • By extending Exception class
  • By implementing Exception interface
  • By using new keyword
  • By using createException method
Show Answer Report

28. What is the purpose of the printStackTrace() method?

  • Prints exception stack trace
  • Handles the exception
  • Prevents exception
  • Ignores exception
Show Answer Report

29. Which exception occurs during arithmetic operations?

  • ArithmeticException
  • MathException
  • CalculationException
  • NumberException
Show Answer Report

30. What is the main advantage of exception handling?

  • Maintains normal program flow
  • Increases program speed
  • Reduces code size
  • Eliminates all errors
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test