Software Development

Java – Override method to not throw Exception

So you have a child and parent classes. The child class extends from the Parent class as follows.


Normally, when overriding a method most of us just copy the same method signature from the parent class.


Here, the overridden method printName throws an Exception as its parent version of printName. This will require any codes calling your overridden method to handle the Exception.

We could change the overridden method’s signature to this.

This will not force your calling codes to declare or handle the exception.

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like