11.) Which of the following is an unchecked exception in Java?
A) IOException
B) NullPointerException
C) FileNotFoundException
D) ClassNotFoundException
12.) What happens if an exception is not caught or declared in a method that throws it?
A) The program will terminate.
B) The compiler will generate an error.
C) The exception is automatically caught and handled by the JVM.
D) It is a runtime exception and does not need to be caught or declared.
13.) Which exception is thrown when a method is called on an object that is null?
A) NullReferenceException
B) NullPointerException
C) ObjectNotFoundException
D) InvalidObjectException
14.) What is the purpose of the “getMessage()” method in the Exception class?
A) It throws an exception.
B) It catches exceptions.
C) It returns a message associated with the exception.
D) It terminates the program.
15.) What happens if an exception is thrown inside a “finally” block?
A) The exception is caught and handled within the “finally” block.
B) The exception is propagated to the caller method.
C) The program will terminate.
D) The exception is suppressed, and the program continues execution.
16.) What does the “try-with-resources” statement in Java do?
A) It is used to catch exceptions.
B) It is used to create custom exceptions.
C) It is used to manage resources that need to be closed after they are no longer needed.
D) It is used to handle unchecked exceptions.
17.) Which exception is thrown when a method is called with an argument of an inappropriate type?
A) TypeMismatchException
B) IllegalArgumentException
C) ClassCastException
D) ArgumentTypeException
18.) Which class is used to handle input and output exceptions in Java?
A) IOException
B) FileException
C) InputOutputException
D) ExceptionIO
19.) What is the purpose of the “printStackTrace()” method in Java exceptions?
A) It prints the exception message.
B) It prints the stack trace of the exception.
C) It prints the line of code that caused the exception.
D) It prints the name of the exception class.
20.) When should you use the “throws” clause in a method signature?
A) When you want to create a custom exception
B) When you want to catch exceptions
C) When you want to indicate that the method may throw exceptions
D) When you want to terminate the program