题目内容

可以使用下面哪个方法强制一个线程等待其它线程执行完毕 (D)A:sleep(long milliseconds)B:yield()C:stop()D:join()public class Base{int x;static int z;public Base() { z++;(1)}Public static void main(String[] args){ int y; Base b=new Base(); System.out.print(Base.z);(2) System.out.print(x);(3) System.out.print(y);(4)}}会出错的语句是()

A. (1)
B. (2)
C. (3)
D. (4)

查看答案
更多问题

13.假设A类有如下定义,设a是A类的一个实例,下列语句调用哪个是错误的?()class A { int i; static String s;void method1() { }static void method2() { }}

A. System.out.println(a.i);
B. a.method1();
C. A.method1();
D. A.method2();

运行以下程序会抛出哪种异常?()publicclassTest{public static void main(String[] args) Object o = null;System.out.println(o);}

ArithmeticException
B. ArrayIndexOutOfBoundsException
C. StringIndexOutOfBoundsException
D. no Exception
E. NullPointerException

执行如下程序后b的值为? ()int x, b=0; for(x = 0; x <= 5; ++x){ if (x == 2) continue; ++b; }

A. 5
B. 4
C. 3

给定如下代码:3. class Alpha {4. static String s = " ";5. protected Alpha() { s += "alpha "; }6. }7. class SubAlpha extends Alpha {8. private SubAlpha() { s += "sub "; }9. }10. public class SubSubAlpha extends Alpha {11. private SubSubAlpha() { s += "subsub "; }12. public static void main(String[] args) {13. new SubSubAlpha();14. System.out.println(s);15. }16. }运行结果为?()

A. subsub
B. sub subsub
C. alpha subsub
D. alpha sub subsub

答案查题题库