Skip to content
Sharp

Core Java · interview question

Given the following code snippet, what will be the output?

Multiple choiceMediumchapter-6-curatedpremiumcore-javacode-reading-with-exceptions
java
public class Order {
    public static void main(String[] args) {
        try {
            System.out.println("Start");
            throw new RuntimeException("Exception");
        } catch (RuntimeException e) {
            System.out.println("Caught");
        } finally {
            System.out.println("Done");
        }
    }
}
Choose one answer
Answer and explanation

Correct answer

C. Start -> Caught -> Done

Why

The method throws an exception, which is caught in the catch block. The finally block executes regardless of whether an exception occurs.

Test yourself on Core Java

A free test with instant, explained results. No account needed.

Start free test
All Core Java questions →