CodesJava

Easy learning with example program codes

will finally block get executed if return?


Yes, finally block will always be executed.

finally:

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



Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap