Home > Back-end >  Java problem
Java problem

Time:09-27

Subclasses throws in option b is greater than the parent class exception, why b is correct?

CodePudding user response:

Can only throw an exception or greater, you said can't throw a smaller exception,

CodePudding user response:

Rewriting: 1, parameter list must be fully and be rewritten in the same way, otherwise can't call it the rewrite but overloading,

2, return type must be rewritten with the method of the return type of the same, otherwise can't call it the rewrite but overloading,

3, the limitation of access modifier must be greater than be rewritten method access modifier (public> Protected> Default> Private)

4, rewriting method must not be thrown new checked exception, or more broadly than be rewritten method statement type check exception
  • Related