Which keyword is used to declare an exception in a method signature?
A
catch B
throw C
throws D
try
Analysis & Theory
`throws` is used to declare that a method may throw one or more exceptions.
Which of the following is an unchecked exception?
A
IOException B
SQLException C
NullPointerException D
FileNotFoundException
Analysis & Theory
`NullPointerException` is an unchecked (runtime) exception.
What type of exception must be either caught or declared in a method?
A
Checked Exception B
Unchecked Exception C
Runtime Exception D
Error
Analysis & Theory
Checked exceptions must be handled using `try-catch` or declared with `throws`.
Which block is always executed whether an exception is thrown or not?
A
catch B
throw C
finally D
try
Analysis & Theory
`finally` block always executes, used for cleanup code.
Which of these classes is the parent of all exceptions?
A
Exception B
Throwable C
RuntimeException D
Error
Analysis & Theory
`Throwable` is the superclass of `Exception` and `Error` classes.
What is the purpose of the `throw` keyword?
A
To catch an exception B
To define an exception C
To manually throw an exception D
To ignore an exception
Analysis & Theory
`throw` is used to explicitly throw an exception.
Which exception is thrown when a number format is invalid?
A
IllegalArgumentException B
IOException C
NumberFormatException D
FormatMismatchException
Analysis & Theory
`NumberFormatException` occurs when trying to convert an invalid string to a number.
Which of the following is a checked exception?
A
ArithmeticException B
FileNotFoundException C
NullPointerException D
IllegalStateException
Analysis & Theory
`FileNotFoundException` is a checked exception that must be handled or declared.
Which statement is true about exception propagation in Java?
A
It occurs from bottom to top in the call stack B
It only works with unchecked exceptions C
It occurs only inside the same method D
It stops after the first catch block
Analysis & Theory
Exceptions propagate up the call stack until caught or the program terminates.
What happens if an exception is not caught and not declared?
A
The program continues normally B
The compiler gives an error (for checked exceptions) C
The JVM skips the method D
It is logged automatically and ignored
Analysis & Theory
For checked exceptions, the compiler throws an error if not caught or declared.