单项选择题 (2010年9月二级考试)

下列程序的运行结果是 【 】

public class test{
    private String[] data={“10”,“10.5”};
    public void fun(){
        double s=0;
        for(int i=0;i<3;i++){
            try{
                s=s+Integer.parseInt(data[i]);
            }catch(Exception e){
                System.out.print(“errorl:”+data[i]);
            }
        }
    }
    public static void main(String[] args){
        try{
            testd=new test();
            d.fun();
        }catch(Exception e){
            System.out.printIn(“error2”);
        }
    }
}

A、error1:10.5

B、error2

C、error1:10.5 error2

D、以上说法都不对

参考答案

关键词

catch;error;try;异常;public;data;捕获;程序;test;try-catch-finally结构;