A.go
B.编译失败
C.代码运行,无输出结果
D.运行时异常被抛出
第1题:
classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione)System.out.print("in");publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print("pre");try{t.join();}catch(Exceptione){}System.out.print("post");可产生哪两项结果?()
A.preinpost
B.prein
C.inpostpre
D.inprepost
E.prepostin
第2题:
publicclassThreads4{publicstaticvoidmain(String[]args){newThreads4().go();}publicvoidgo(){Runnabler=newRunnable(){publicvoidrun(){System.out.print(”foo”);}};Threadt=newThread(r);t.start();t.start();}}Whatistheresult?()
A.Compilationfails.
B.Anexceptionisthrownatruntime.
C.Thecodeexecutesnormallyandprints?foo”.
D.Thecodeexecutesnormally,butnothingisprinted.
第3题:
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是
A.Test t=new Test();
B.Thread t=new Thread();
C.Thread t=new Thread(new Test());
D.Test t=new Thread();
第4题:
A.go
B.运行时异常被抛出
C.代码运行,无输出结果
D.编译失败
第5题:
阅读下面程序 public class Test implements Runnable{ public static void main(String[]args){ _______________________________________; t. start(); } public void mR(){ System. out. println("Hello!"); }} 在程序下画线处填入正确选项是
A.Test t=flew Test()
B.Thread t=new Thread();
C.Thread t=new Thread(new Test());
D.Test t=new Thread();