Exception Handling
6.What is the difference between throw and throws?
-
A. throw is used inside a method, throws is used in the method signature
-
B. Both are the same
-
C. throws is used to catch exceptions, throw is used to declare exceptions
-
D. throw is used to catch exceptions, throws is used inside a method
throw is used inside a method, throws is used in the method signature
throw is used inside a method, throws is used in the method signature
7.Which of the following blocks is always executed in a try-catch-finally structure?
-
A. try
-
B. catch
-
C. finally
-
D. None of the above
finally
finally
8.What type of exceptions are checked exceptions?
-
A. Exceptions that are checked by the compiler at compile time
-
B. Exceptions that occur only at runtime
-
C. Exceptions that extend RuntimeException
-
D. Exceptions that extend Error
Exceptions that are checked by the compiler at compile time
Exceptions that are checked by the compiler at compile time
9.Which of the following is an example of an unchecked exception?
-
A. IOException
-
B. SQLException
-
C. ArithmeticException
-
D. InterruptedException
ArithmeticException
ArithmeticException
10.What is the purpose of the try block in Java?
-
A. To declare exceptions
-
B. To execute code that might throw an exception
-
C. To handle exceptions
-
D. To ignore exceptions
To execute code that might throw an exception
To execute code that might throw an exception