An exception travelling up through finally
Predict the outputMediumJava only
public class Main {
static void outer() {
try {
inner();
System.out.println("after inner");
} finally {
System.out.println("outer finally");
}
}
static void inner() {
System.out.println("inner start");
throw new RuntimeException("boom");
}
public static void main(String[] args) {
try {
outer();
} catch (RuntimeException e) {
System.out.println("caught " + e.getMessage());
}
System.out.println("end");
}
}
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.