An exception thrown inside finally
Predict the outputMedium-HardJava only
public class Main {
public static void main(String[] args) {
try {
try {
throw new RuntimeException("first");
} finally {
throw new IllegalStateException("second");
}
} catch (RuntimeException e) {
System.out.println(e.getMessage());
System.out.println(e.getClass().getSimpleName());
System.out.println(e.getSuppressed().length);
}
}
}
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.