Function of Try-Catch-Finally block

Describe the function of Try-Catch-Finally block?

E

Expert

Verified

The try block includes those statements which can cause exception and a catch block handles an exception, if it happens. Catch block includes the statements which have to be executed, when the exception occurs. The finally block always executes, irrespective of the fact that an exception has occurred or not. Finally block is usually used to do the cleanup process. If some exception occurs in a try block, the program control directly transfers to its equivalent catch block and afterwards to a finally block. If no exception occurs into the try block, then a program control transfers directly to a finally block.

   Related Questions in Software Engineering

©TutorsGlobe All rights reserved 2022-2023.