Exceptions Questions and Answers
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
22. What happens if an exception is not caught?
- Program terminates if reaches main method
- Program continues normally
- Exception is ignored
- Automatic recovery
23. Which method returns the description of an exception?
- getMessage()
- toString()
- printStackTrace()
- getDescription()
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
25. Which exception occurs when a file is not found?
- FileNotFoundException
- IOException
- FileException
- NoFileException
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
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
28. What is the purpose of the printStackTrace() method?
- Prints exception stack trace
- Handles the exception
- Prevents exception
- Ignores exception
29. Which exception occurs during arithmetic operations?
- ArithmeticException
- MathException
- CalculationException
- NumberException
30. What is the main advantage of exception handling?
- Maintains normal program flow
- Increases program speed
- Reduces code size
- Eliminates all errors