| 1. | What is the purpose of an exception? | |
| 2. | What class serves as the root of all Errors and Exceptions? | |
| 3. | What’s the difference between a checked and an unchecked exception? | |
| 4. | (True/False) You must explicitly handle an unchecked exception. | |
| 5. | What’s the purpose of a try/catch statement? | |
| 6. | How many catch clauses can a try/catch statement contain? | |
| 7. | What’s the purpose of the finally clause? | |
| 8. | (True/False) Both the catch and finally clauses can be simultaneously omitted from a try/catch/finally statement. | |
| 9. | What’s the purpose of a throws clause? | |
| 10. | In what order should you catch exceptions? | |
Answers
| 1. | - to signal the occurrence of an error condition |
| 2. | - java.lang.Throwable |
| 3. | - you do not have to explicitly handle unchecked exceptions, although it is sometimes a good idea to do so |
| 4. | - false |
| 5. | - statements that may throw a checked exception must be enclose inside a try block. The catch block is used to catch and handle the exception when thrown. |
| 6. | - as many as required |
| 7. | - The finally clause contains statements that will be executed when an exception occurs. Usually contains cleanup code. |
| 8. | - false |
| 9. | - The throws clause is used to indicate that a method will throw a particular type of exception. |
| 10. | - From specific to general |