20
Checked and Unchecked Exceptions
•If the code in a method can throw a checked exception, the method:
–must handle the exception, or
–it must have a throws clause listed in the method header.
•The throws clause informs the compiler what exceptions can be thrown from a method and avoids a compile time error
The thrwo statement causes and exception to be thrown.
The throws clause informs the compiler that a method throws one or more exceptions