Cognizant Interview Question

What is a finally block? Is there a case when finally will not execute?

Interview Answer

Anonymous

Dec 28, 2018

Finally block is a block which always executes a set of statements. It is always associated with a try block regardless of any exception that occurs or not. Yes, finally will not be executed if the program exits either by calling System.exit() or by causing a fatal error that causes the process to abort.

1