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
11. Which of these is a checked exception in Java?
- RuntimeException
- IOException
- NullPointerException
- ArithmeticException
12. What is the parent class of all exceptions in Java?
- Throwable
- Exception
- Error
- Object
13. Which keyword is used to explicitly throw an exception?
- throws
- throw
- try
- catch
14. Which block is used to handle exceptions in Java?
- try-catch
- throw-catch
- exception-handle
- error-handle
15. Which block is always executed regardless of whether an exception occurs or not?
- finally
- catch
- throw
- throws
16. What is the output when a NullPointerException occurs?
- Runtime exception when using null object reference
- Compile time error
- Warning message
- No output
17. Which of these exceptions is related to array operations?
- ArrayIndexOutOfBoundsException
- NullPointerException
- ClassCastException
- IOException
18. What does the try-with-resources statement ensure?
- Automatic resource closure
- Manual resource management
- Exception suppression
- No exception handling
19. Which exception occurs when converting invalid string to number?
- NumberFormatException
- IllegalArgumentException
- ParseException
- FormatException
20. What is the purpose of the throws keyword?
- Declare exceptions in method signature
- Throw an exception
- Catch an exception
- Handle an exception