References


Self-Test Questions

1. 

What is the purpose of an exception?

 - to signal the occurrence of an error condition

2. 

What class serves as the root of all Errors and Exceptions?

image from book

3. 

What’s the difference between a checked and an unchecked exception?

image from book

4. 

(True/False) You must explicitly handle an unchecked exception.

image from book

5. 

What’s the purpose of a try/catch statement?

image from book

6. 

How many catch clauses can a try/catch statement contain?

image from book

7. 

What’s the purpose of the finally clause?

image from book

8. 

(True/False) Both the catch and finally clauses can be simultaneously omitted from a try/catch/finally statement.

image from book

9. 

What’s the purpose of a throws clause?

 - the throws clause is used to indicate that a method will throw a particular type of exception.

10. 

In what order should you catch exceptions?

 - from specific to general

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




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net