Let us first try to understand this Java interview question. You can see below is a simple Java code which where in we have put a return statement in the try block. So the question is will finally block execute.
public static void main(String args)
// will the control come here
The answer is Yes Finally block will execute irrespective there is return or there are no return statements. That’s why finally block is the best place to put clean up code.
You can also see our Java j2ee interview question and answer video: - what is service locator?