Review Lesson 7 of Beginning Java. Summary: Exceptions An exception is a way for one part of your program to communicate an error to another part. By handling an exception you can gracefully resolve the error, rather than crashing your program and dumping a load of garbage onto the user's screen. Exceptions are classes like the ones we've already worked with and written. They are subclasses of java.lang.Exception, and they can inherit from one another to create an Exception hierarchy. Exceptions usually signify recoverable errors. Unrecoverable errors like hardware failure are dealt with using the java.lang.Error class. Errors can't be caught - they cause your program to automatically exit. You use a try-catch block to catch possible exceptions. You can optionally add a finally block to a try-catch block. The code in the try block is run, and if an exception occurs, the code in the catch block is executed. The code in the finally block is executed no matter what happens. You can throw your own exceptions using the throw keyword. If a method generates an exception and doesn't catch it, the method that calls it must handle the exception. Some methods are declared with a throws clause, warning you that they can throw certain types of exceptions. When you call these methods, you must enclose the call in a try-catch block.