When we say "finally", we mean something that we were waiting for or something that is going to conclude the process. This is almost the same in exception handling. A finally block is a block of code that will be executed no matter what happens in the try or catch block. It doesn't matter what types of exception were thrown or whether or not they were handled, the finally block will be executed. Now you may ask, "Why do we need this finally block? If there is any exception in our program, we will handle it with the catch block! Can't we write the code inside the catch block instead of the finally block?"
Yes, you can, but what happens if an exception was thrown but the catch block wasn't triggered? This would mean that the code inside the catch block will not get executed. For this reason, the finally block is...