When both the try block and its finally block throw, the finally block's exception is the one that actually propagates to the caller; the original exception from try is discarded unless it was explicitly attached first.
try {
try {
throw new RuntimeException("from try");
} finally {
throw new IllegalStateException("from finally");
}
} catch (Exception e) {
System.out.println("Propagated: " + e.getClass().getSimpleName() + ": " + e.getMessage());
}
Propagated: IllegalStateException: from finally
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-09-27