If you choose to both handle the exception (using try/catch) and duck the exception(using throws clause), compiler chooses to handle the exception.
In your case, it will catch the exception and assign 5
to number
.
And a Suggestion:
its a bad practice to handle all exceptions inside a single catch block, i.e.,
catch(Exception e)
always catch most Specific exceptions.