恢复哪些线程的执行( )
A. 通过调用stop()方法而停止的线程。
B. 通过调用sleep()方法而停止运行的线程。
C. 通过调用wait()方法而停止运行的线程。
D. 通过调用suspend()方法而停止运行的线程。
19、有关线程的哪些叙述是对的( )
A. 一旦一个线程被创建,它就立即开始运行。
B. 使用start()方法可以使一个线程成为可运行的,但是它不一定立即开始运行。
C. 当一个线程因为抢先机制而停止运行,它被放在可运行队列的前面。
D. 一个线程可能因为不同的原因停止(cease)并进入就绪状态。
20、给出下面的不完整的方法,下面的哪些声明可以被加入第一行完成此方法的声明:下面的哪些声明可以完成此方法的声明。TimedOutException 不是一个RuntimeException( )
1)
2) { success = connect()
3} if (success==-1) {
4} throw new TimedOutException();
5} }
6}}
A. public void method()
B. public void method() throws Exception
C. public void method() throws TimedOutException
D. public void method() throw TimedOutException
E. public throw TimedOutException void method()
22、给出下面的不完整的类代码:下面的哪些表达式可以加到构造方法中的”doing the same as…”处?( )
class Person {
String name, department;
int age;
public Person(String n){ name = n; }
public Person(String n, int a){ name = n; age = a; }
public Person(String n, String d, int a) {
// doing the same as two arguments version of constructor
// including assignment name=n,age=a
department = d;
}
}
A. Person(n,a); B. this(Person(n,a)); C. this(n,a); D. this(name,age).
23、在oneMethod()方法运行正常的情况下将显示什么?( )
public void test() {
try { oneMethod();
System.out.println(“condition 1″);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println(“condition 2″);
} catch(Exception e) {
System.out.println(“condition 3″);
} finally {
System.out.println(“finally”);
}
}
A. condition 1 B. condition 2 C. condition 3 D. Finally
24、给出下面的代码:输出将是什么( )
public class Test {
void printValue(int m){
do { System.out.println(“The value is”+m);
}
while( –m > 10 )
}
public static void main(String arg[]) {
int i=10;
Test t= new Test();
t.printValue(i);
}
}
A. The value is 8 B. The value is 9 C. The value is 10 D. The value is 11
25、给出下面的代码:哪些行在编译时可能产生错误( )
1) public void modify() {
2) int i, j, k;
3) i = 100;
4) while ( i > 0 ) {
5) j = i * 2;
6) System.out.println (” The value of j is ” + j );
7) k = k + 1;
8) i–;
9) }
10} }
A.line 4 B. line 6 C. line 7 D. line 8
26、给出下面的代码片断:…哪些行将导致错误( )
1) String str = null;
2) if ((str != null) && (str.length() > 10)) {
3} System.out.println(“more than 10″);
4} }
5) else if ((str != null) & (str.length() < 5)) {
6} System.out.println(“less than 5″);
7} }
8) else { System.out.println(“end”); }
A. line 1 B. line 2 C. line 5 D. line 8
27、 给出下面的代码:… 哪些叙述是对的( )
public class Person{
int arr[] = new int[10];
public static void main(String a[]) {
System.out.println(arr[1]);
}
}
A. 编译时出错。 B. 编译时正确而运行时出错。 C. 输出0。 D. 输出null
28、哪些方法可以加入类Child中( )
public class Parent {
public int addValue( int a, int b) {
int s;
s = a+b;
return s;
}
}
class Child extends Parent {
}
A. int addValue( int a, int b ){// do something…}
B. public void addValue (){// do something…}
C. public int addValue( int a ){// do something…}
D. public int addValue( int a, int b )throws MyException {//do something…}
29、共有成员变量MAX_LENGTH是一个int型值,变量的值保持常数值100。使用一个短声明定义这个变量( )
A. public int MAX_LENGTH=100;
B. final int MAX_LENGTH=100;
C. final public int MAX_LENGTH=100;
D. public final int MAX_LENGTH=100.
30、哪些返回true( )
String s= “hello”;
String t = “hello”;
char c[] = {‘h’,'e’,'l’,'l’,'o’} ;
A. s.equals(t); B. t.equals(c); C. s==t; D. t.equals(new String(“hello”)); E. t==c.
31、类Teacher和Student都是类Person的子类,
Person p;
Teacher t;
Student s;
p, t and s are all non-null.
if(t instanceof Person) { s = (Stud