Given:
class Main {/* w w w . jav a2s .c o m*/ static String s = "-"; public static void main(String[] args) { new Main().method1(); System.out.println(s); } void method1() { try { method2(); } catch (Exception e) { s += "c"; } } void method2() throws Exception { method3(); s += "2"; method3(); s += "2b"; } void method3() throws Exception { throw new Exception(); } }
What is the result?
B is correct.
Once method3() throws the exception to method2(), method2() throws it to method1(), and no more of method2()'s code will be executed.