以下はException handlingメカニズムを伝播しているクラスQuestionです。目的の出力はExceptionです。なぜ例外が出力されたのかを誰にも説明できますか?次のステップは、プログラム実行の一部として起こるコア-java例外処理
Class Question {
public void m1() throws Exception {
try {
m2();
} finally {
m3();
}
}
public void m2() throws RuntimeException {
throw new RuntimeException();
}
public void m3() throws Exception {
throw new Exception();
}
public static void main(String[] args) throws Exception {
Question q = new Question();
try {
q.m1();
} catch (RuntimeException re) {
System.out.println("RuntimeException");
} catch (Exception e) {
System.out.println("Exception");
}
}
m1が例外をスローするため – Ravi
最終的にブロックされた場合、m2()メソッドは何を出力しますか? –
最終的にブロック内でm2()メソッドを呼び出すと出力は何ですか? RuntimeException – developer