(31)如果使用Thread t=new Test()语句创建一个线程,则下列叙述正确的是( )。
A. Test类一定要实现Runnable接口
B. Test类一定是Thread类的子类
C. Test类一定是Runnable的子类
D. Test类一定是继承Thread类并且实现Runnable接口
(32)作为程序入口的main()方法的返回类型是()。
A. int B. void C. boolean D.static
(33)下面程序运行后得到的结果是()。
1. public class SwitchTest{
2.public static void main (String [ ] args{
3.System.out.PrintIn (“value = switchIt (4));
4.}
5.public static int swichIt (int x ) {
6.int j = 1
7.switch (x) {
8.case 1: j++ ;
9.case 2: j++ ;
10.case 3: j++;
11.case 4: j++;
12.case 5: j++;
13.default : j++;
14.}
15.return j + x;
16.}
17.}
A. Value = 3
B. Value = 4
C. Value = 7
D. Value = 8
(34)下列程序的功能是在监控台上每隔一秒现实一个字符串“Hello”,能够填写在程序中适当的位置,是程序完整并能正确运行的语句是( )
public class Test implements Runnable{
public static void main (String args[ ]){
Test =new Test ( );
Thread tt = new Thread(t) ;
tt.start( );
}
public void run( ){
for(;;){
try{
;
}catch(e){}
System.put.println(“Hello”);
}
}
}
A.sleep(1000) InterruptedException
B.sleep(1000) InterruptedException
C.Thread.sleep(1000) RuntimeException
D.Thread.sleep(1000) InterruptedException
(35)阅读下列代码
public class Person {
int arr [ ] =new int[10];
arr[1] = 9;
public static void main (Stering args[ ]){
System.out.println(arr[1]);
}
}
正确的说法是( )
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出零
D. 输出空
选择题答案
(11)A(12)D(13)A(14)A(15)B(16)C(17)D(18)D(19)C(20)B(21)C(22)C(23)A24)C(25)C(26)A(27)C
(28)C(29)D(30)C(31)B(32)B(33)D(34)D35)A