Easy learning with example program codes

will finally block get executed if return?

Yes, finally block will always be executed.


finally block is mainly used to do clean-up task. It is always executed even when no exception occur. It will not execute only in case program exits using System.exit() or because of some fatal error cause program to abort. It is followed by either catch or try block.

Note: A try block can have one or more catch block associated with it, but only one finally block can be associates with it. 

Java interview questions on exception handling

Please follow and like us:

Copyright © 2020 CodesJava Protection Status