Can a program run without a catch block? How would you use try and finally together?

Yes, it is possible to use a try block without a catch block in Java, provided it is followed by a finally block. In this case, any exception thrown in the try block is not handled locally and propagates to the caller, while the finally block still executes to perform cleanup operations.

Key Points

Example

A method may open a file inside the try block and close it in the finally block, while allowing any exception to be handled by the caller.

public class Demo {

    public static void main(String[] args) {

        try {
            int result = 10 / 0;
        } finally {
            System.out.println("Cleanup code executed");
        }
    }
}

Output

Cleanup code executed

Exception in thread "main" java.lang.ArithmeticException: / by zero

Interview Tip

A concise interview answer is

Yes, Java allows a try block without a catch block if it is followed by a finally block. In such cases, the exception is propagated to the caller, but the finally block still executes, making it useful for resource cleanup and releasing system resources.

Last updated: 11 November 2026

Previous question: What happens if a return statement is executed inside the try or catch block? Does the finally block still execute?

Next question: How does exception handling with try-catch-finally affect the performance of a Java application?

More Core Java - Level II interview questions

All Core Java - Level II questions