1.Java中,运行以下语句的输出是什么?
try {
System.out.println(true?(Integer)null:1);
} catch (Exception e) {
System.out.println(6);
}
A. null
B. 6
C. 1
D. 0
2.Javascript中,语句中的 x 最后值为多少?
var [x=1] = [[14,2,null,[9,7,4][21,1],1,undefined][3]];
console.log(x);
A. 7
B. 1
C. 9
D. undefined
3.Java中,运行以下代码会得到什么结果?
public class Test {
public static int method(){
return 1;
}
public static void main(String[] args) {
Test t = null;
System.out.println(t.method());
}
}
A. null
B. 1
C. NullPointerException
D. 0
4.Java中,运行以下代码会得到什么结果?
public class Test {
public int method(){
try {
int i = 5 / 0;
return 1;
} catch (Exception e){
return 2;
} finally {
return 3;
}
}
public static void main(String[] args) {
Test t = new Test();
System.out.println(t.method());
}
}
A. 3
B. 1
C. 2
D. 0
5.Java中,运行以下代码会得到什么结果?
public class Test {
public int method(){
int i = 0;
try {
i += 1;
return i;
} catch (Exception e){
i += 2;
} finally {
i += 3;
}
return i;
}
public static void main(String[] args) {
Test t = new Test();
System.out.println(t.method());
}
}
A. 1
B. 0
C. 4
D. 2