一.单选题(20分)
1.下面哪些不是JAVA的基本数据类型 ( C )
A、long B、float C、String D、double
2.表达式“5 / 2”的结果:( A )
A. 2
B. 2.5
C. 2.555555
D. 3
3.下面程序运行的结果是:( A )
public class X {
private static int a;
public static void main(String [] args) {
modify(a);
System.out.println(a);
}
public static void modify(int a) {
a++;
}
}
A. 0
B. 1
C. 程序编译失败
D. 程序运行抛出异常
4.下面都属于线程安全的类是:(B D)
A. ArrayList
B. Vector
C. HashMap
D. Hashtable
5.根据代码选择输出结果:( C)
public class Ob {
private static int a = 0;
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
a += i;
new Thread(new Runnable() {
public void run() {
System.out.print(a + " ");
}
}).start();
}
}
}
A. 0 1 2 3 4
B. 1 2 3 4 5
C. 不确定
D. 5 4 3 2 1
6.根据代码选择输出结果:(B )
int i = 0, j = 1;
if ((i++ == 1) && (j++ == 2)) {
i = 42;
}
System.out.println("i = " + i + ", j = " + j);
A. i=1,j=2
B. i=1,j=1
C. i=42,j=2
D. i=42,j=1
7.下面程序运行的结果是:( A )
import java.io.IOException;
public class ExceptionTest{
public static void main (String[]args) {
try {
me
java选择题
![](https://img-home.csdnimg.cn/images/20240711042549.png)