Saved Bookmarks
| 1. |
Is it possible to override a method to throw RuntimeException from throwing NullPointerException in the parent class? |
|
Answer» Yes, this is possible. But it is not possible if the parent class has a checked Exception. This is due to the below rule of method overriding in cases of checked exceptions:
This means that if the overridden method is throwing IOException, then the overriding child class method can only throw IOException or its sub-classes. This overriding method can not throw a higher Exception than the original or overridden method. |
|