The try block encloses those statements that can cause exception and the catch
block handles the exception, if it occurs. Catch block contains the
statements that have to be executed, when an exception occurs. The finally block always executes, irrespective of the fact whether or not an exception has occurred. The finally block is generally used to perform the cleanup process. If any exception occurs in the try block, the program control directly transfers to its corresponding catch block and later to the finally block. If no exception occurs inside the try block, then the program control transfers directly to the finally block.
Example:-
Example:-
No comments:
Post a Comment