Exceptions
- Which part of code gets executed whether exception is caught or not?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Finally block of the code gets executed regardless exception is caught or not. File close, database connection close, etc are usually done in finally.
- Which of the following keyword is used by calling function to handle exception thrown by called function?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
A method specifies behaviour of being capable of causing exception. Throws clause in the method declaration guards caller of the method from exception.
- Which of the following handles the exception when a catch is not used?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Default handler is used to handle all the exceptions if catch is not used to handle exception. Finally is called in any case.
- Which of the following operators is used to generate instance of an exception which can be thrown using throw?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
new operator is used to create instance of an exception. Exceptions may have parameter as a String or have no parameter.
- Which of the following should be true of the object thrown by a thrown statement?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
The throw statement should be assignable to the throwable type. Throwable is the super class of all exceptions.