posted 21 years ago
Right - when an exception is thrown, it will be caught by the nearest matching catch block. If the exception is thrown within a try block that has a matching catch block and/or finally block, the exception is handled there.
If the exception is thrown within a try block without a matching catch or finally block (or it's a RuntimeException), the exception will be propogated to the method that invoked this one. It will then be handled there or, if that method doesn't handle the exception, it will propogate to the method that invoked that one, and so on.
Of course, if you're not going to handle a given exception within a method that might throw one, you must declare that the method in question is capable of throwing such an exception (by adding "throws Exception" to the end of the method signature). Once you've done that, any methods that invoke this one will be required to handle that exception (or throw it).