問題一覧へ 例外処理 基礎

マルチキャッチ

次のコードを引数なしで実行すると何が表示されますか。

public class Main {
  public static void main(String[] args) {
    try {
      if (args.length == 0)
        throw new IllegalArgumentException("no args");
      else
        throw new NullPointerException("null found");
    } catch (IllegalArgumentException | NullPointerException e) {
      System.out.println("caught: " + e.getMessage());
    }
  }
}

選択肢