About Question enthuware.ocajp.i.v8.2.945 :
Posted: Wed Feb 24, 2016 6:07 am
On this statement:
An overriding method cannot exhibit behavior that contradicts the declaration of the original method. An overriding method therefore cannot return a different type (except a subtype) or throw a wider spectrum of exceptions than the original method in the superclass.
I think the part in red is wrong, you can throw any unchecked exception or error (not a good practice though) from the overriding method.
Am I right?
An overriding method cannot exhibit behavior that contradicts the declaration of the original method. An overriding method therefore cannot return a different type (except a subtype) or throw a wider spectrum of exceptions than the original method in the superclass.
I think the part in red is wrong, you can throw any unchecked exception or error (not a good practice though) from the overriding method.
Am I right?