21.) Which exception is thrown when a file is not found during input/output operations?
A) FileNotFoundException
B) FileNotFound
C) IOErrorException
D) FileException
22.) What is the purpose of the “assert” statement in Java?
A) To handle exceptions
B) To specify that a method is deprecated
C) To check a condition and throw an exception if it is false
D) To catch exceptions
23.) Which exception is thrown when a program tries to divide a number by zero?
A) DivideByZeroException
B) ArithmeticException
C) ZeroDivisionException
D) MathError
24.) In a multi-catch block, what must be the relationship between the exception types?
A) They must all be checked exceptions.
B) They must all be unchecked exceptions.
C) They must be related by inheritance, with the most specific exception type first.
D) They must be unrelated and can be in any order.
25.) What is the purpose of the “try” block in exception handling?
A) To catch exceptions
B) To specify the code that may throw exceptions
C) To handle and process exceptions
D) To terminate the program
26.) What happens if a “finally” block contains a “return” statement?
A) The program will not compile.
B) The “finally” block will be ignored.
C) The “return” statement in the “finally” block will override any “return” statements in the “try” or “catch” blocks.
D) The program will throw a runtime exception.
27.) What is the purpose of the “Throwable” class in Java exception hierarchy?
A) It is the base class for all exceptions.
B) It is used to handle exceptions.
C) It is the root class for checked exceptions.
D) It is the root class for unchecked exceptions. A
28.) Which exception is thrown when a program exhausts its stack due to excessive method calls?
A) StackOverflowError
B) OutOfMemoryError
C) TooManyCallsException
D) RecursiveCallException
29.) What is the difference between checked and unchecked exceptions?
A) Checked exceptions are always caught by the compiler, while unchecked exceptions are not.
B) Checked exceptions must be caught or declared, while unchecked exceptions do not need to be.
C) Checked exceptions are more severe than unchecked exceptions.
D) Checked exceptions are related to syntax errors, while unchecked exceptions are related to logic errors. B
30.) Which exception is thrown when a method is called on an object that is not properly initialized?
A) InitializationException
B) optObjectNotInitializedExceptionion2
C) NullPointerException
D) UninitializedObjectException