单选题:分析以下程序:
分析以下程序:
public class Test {
public static void main(String[] args) {
try {
String s = "5.6";
Integer.parseInt(s);
int i = 0;
int y = 2 / i;
System.out.println("Welcome to Java");
}
catch (Exception ex) {
System.out.println(ex);
}
}
}
程序会出现( )
A.由于Integer.parseInt(s)出现一个异常。
B.由于2 / i出现一个异常。
C.程序有编译错误。
D.程序编译和运行都没有异常。
答案:A
public class Test {
public static void main(String[] args) {
try {
String s = "5.6";
Integer.parseInt(s);
int i = 0;
int y = 2 / i;
System.out.println("Welcome to Java");
}
catch (Exception ex) {
System.out.println(ex);
}
}
}
程序会出现( )
A.由于Integer.parseInt(s)出现一个异常。
B.由于2 / i出现一个异常。
C.程序有编译错误。
D.程序编译和运行都没有异常。
答案:A