5.5) Will a finally block execute even if the catch block defines a return statement?

Example:

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class ReturnFromCatchBlock {
	public static void main(String[] args) {
		openFile();
	}

	private static void openFile() {
		FileInputStream fis = null;
		try {
			fis = new FileInputStream("file.txt");
		} catch (FileNotFoundException fnfe) {
			System.out.println("file not found");
			return;
		} finally {
			System.out.println("finally");
		}
		System.out.println("Next task..");

	}
}

Last updated