Rules for exception
Rule 1: If the super class method does not declare an exception, then the overriding method in the subclass cannot declare a checked exception, but can declare an unchecked exception.
Rule 2: If the super class method declares an exception, then the overriding method in the subclass can declare same exception or a subclass exception or no exception at all, but cannot declare parent exception
Rule 1: If the super class method does not declare an exception, then the overriding method in the subclass cannot declare a checked exception, but can declare an unchecked exception.
Rule 2: If the super class method declares an exception, then the overriding method in the subclass can declare same exception or a subclass exception or no exception at all, but cannot declare parent exception
Comments
Post a Comment