Sobes.tech
Junior — Senior

Returning a value from finally: what will the calling code receive

livecode

Task condition

Determine what value will be returned by the gring() method when it is executed. Consider the order of exception handling and the fact that the return operator in the finally block overrides any thrown exceptions.

public String gring() {
    try {
        throw new IllegalStateException("Error 1");
    } catch (IllegalStateException ex) {
        throw new IllegalStateException("Error 2", ex);
    } finally {
        return "{ in brackets }";
    }
}