Yes, the finally block executes even if a return statement is encountered inside the try or catch block. Before the method actually returns control to the caller, the JVM ensures that the finally block is executed, making it ideal for resource cleanup activities.
If a method returns a value from the try block, Java first executes the finally block and then returns the value to the caller.
public class Demo {
public static int getValue() {
try {
return 10;
} finally {
System.out.println("Finally block executed");
}
}
public static void main(String[] args) {
System.out.println(getValue());
}
}Finally block executed
10
A concise interview answer is
Yes, the finally block executes even if a return statement is present in the try or catch block. The JVM always executes the finally block before the method actually returns, which makes it useful for performing cleanup operations.
Last updated: 16 July 2026
Previous question: Can you explain the role of each try, catch, and finally block in exception handling?
Next question: Can a program run without a catch block? How would you use try and finally together?