I have one fundamental question when it comes exception handling.I have written below program to convey my question clearly.I have written a program to calculate the square root of a number and I have done exception handling incase user enters negative number.My doubt here is I hear all the time I hear that program continues its execution once the exception it caught is handled.So in my program also I handled the exception.But it doesnt make any sense for the program to continue further with execution after user entered the negative number.Why programs will execute further even after they catch an exception? I am not able to visualisze.Could you please help? I ideally assume that program should abort or exit once an exception is caught orhandled because the data it needs is not given appropriately by the user.
Why programs will execute further even after they catch an exception? I am not able to visualisze.Could you please help? I ideally assume that program should abort or exit once an exception is caught orhandled because the data it needs is not given appropriately by the user.
But that's up to the developer to decide. Not every exception from every part of my program might be fatal. It might mean simply that one action has failed, but that the software can continue to perform other operations.
You, as the programmer, must decide on the appropriate action your program should take when an exception is caught.