04/03/08 22:22
一応,ひっかけ・・・
以下のコードのコンパイル・実行結果は?
01 class Sample{
02 static byte b;
03 public static void main(String[] args){
04 try{
05 method();
06 }
07 catch(Exception e){
08 System.out.println(e);
09 }
10 }
11 static void method(){
12 switch(b){
13 case 1: throw new RuntimeException("1");
14 break;
15 case 2: throw new RuntimeException("2");
16 break;
17 default: throw new RuntimeException("3");
18 }
19 }
20 }
1.java.lang.RuntimeException: 3
2.11行目でコンパイルエラー
3.13行目で実行時エラー
4.14行目でコンパイルエラー
5.17行目で実行時エラー