I am confused .Class Inner throws Exception,but InnerA throws Error,InnerB throws RuntimeException.I remembered that the overridden method can't throw Exception that never throw,but according to this piece of code,it seems right??Why??
- Error is not an exception. - The rule that overridden method can't throw Exception that never throw apply only checked exception,so InnerB can throw RuntimeException without problems.
An overriding method may only throw a subset (possibly empty) of the set of checked exceptions declared to be thrown by the overridden method. RuntimeException and its subclasses, and Error and its subclasses are not checked exceptions so the above rule is not applicable. -Barry