Checked exceptions
- any subclass extend Exception, including Exception itself, excluding RuntimeException
- must be catch or declare in a throws clause.
- represent invalid conditions outside the direct control of the program, Such as wrong format of user input, (which we were dealing a lot during the implementation of A2 in CSC207), database problems, etc
Unchecked exceptions
- extend RuntimeException only, but notice, RuntimeException itself is a subclass of Exception
- the programmer may not know that this kind of exceptions could be thrown, thus, they are not forced to be declared.
- represent bugs in the program, which cannot be reasonably recovered from at run time. Such as NullPointerException, IndexOutOfBoundsException etc.
No comments:
Post a Comment