posted 20 years ago
Hi Angela,
Any method invoking <code>methodA()</code>, in your last example, must catch or throw either SubException, SuperException or Exception.
Superclasses of exceptions can always be used; just remember to order your catch statements with the most specific exception first.
For example, if the invoking method had the following try-catch block:
When <code>methodA()</code> throws <code>SubException</code> it will be caught in the <code>SuperException</code> catch block. If you really want to handle <code>SubException</code> seperately from <code>SuperException</code> then you'd need to reverse their order in the catch statements.
If you catch <code>Exception</code> in the first catch block, it will end up trapping any <code>Exception</code> subclass.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform