AAA
BBB
Compilation fails.
The code runs with no output.
第1题:
阅读下面程序 public class Test2______ { public static void main(String[] args){ Thread t=new Test2(); t. start(); } public void run(){ System. out. priatln("How are you. "); } } 在程序下画线处填入的正确的选项是
A.implements Thread
B.extends Runnable
C.implements Runnable
D.extends Thread
第2题:
在下面程序的下画线处应填入的选项是 public class Test______{ public static void main(String args[]) { Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run() { for(int i=0;i<5;i++) System.out.println("i="+i); } }
A.implements Runnable
B.extends Thread
C.implements Thread
D.extends Runnable
第3题:
3下碳程序段的输出结果是( )。 class Test{ public static void main(Srting args[]){ MyThread t=new MyThread(); t.displayOutput("t has been created"); t.start(); } } class MyThread extends Thread{ public void displayOutput(String s){ SYStem.out.println(s); } public void run() { displayOutput("t is running."); } }
A.t has been created.
B.t has been created. t is running.
C.t is running.
D.编译出错
第4题:
阅读下面程序 public class Test2 ______ { public static void main(String[] args) { Thread t=new Test2(); t.start(); } public void run() { System.out.println("How are you."); } } 程序中下画线处应填入的正确选项是
A.implements Thread
B.extends Runnable
C.implements Runnable
D.extends Thread
第5题:
( 30 )在程序的下划线处应填入的选项是
public class Test _________{
public static void main(String args[]){
Test t = new Test();
Thread tt = new Thread(t);
tt.start();
}
public void run(){
for(int i=0;i<5;i++){
system.out.println( " i= " +i);
}
}
}
A ) implements Runnable
B ) extends Thread
C ) implements Thread
D ) extends Runnable
第6题:
public class A extends Thread { A() { setDaemon(true); } public void run() { (new B()).start(); try { Thread.sleep(60000); } catch (InterruptedException x) {} System.out.println(“A done”); } class B extends Thread { public void run() { try { Thread.sleep(60000); } catch (InterruptedException x) {} System.out.println(“B done”); } } public static void main(String[] args) { (new A()).start(); } } What is the result?()
第7题:
现有: class ThreadBoth extends Threaa implements Runnable { public void run() (System.out.print("hi"); } public static voicl main (String [] args) { Thread tl=new ThreadBoth(): Thread t2 = new Thread (tl): tl.run(): t2.run(): } 结果为:()
第8题:
Compilation fails.
An exception is thrown at runtime.
Synchronizing the run() method would make the class thread-safe.
The data in variable “x” are protected from concurrent access problems.
Declaring the doThings() method as static would make the class thread-safe.
Wrapping the statements within doThings() in a synchronized(new Object()) {} block would make the class thread-safe.
第9题:
0
1
2
3
第10题:
new Thread() {public void run() { doStuff(); }};
new Thread() {public void start() { doStuff(); }};
new Thread() {public void start() { doStuff(); }}.run();
new Thread() {public void run() { doStuff(); }}.start();
new Thread(new Runnable() {public void run() { doStuff(); }}).start();
第11题:
new Thread() { public void run() { doStuff(); } }
new Thread() { public void start() { doStuff(); } }
new Thread() { public void start() { doStuff(); } } .run();
new Thread() { public void run() { doStuff(); } } .start();
new Thread(new Runnable() { public void run() { doStuff(); } } ).run();
new Thread(new Runnable() { public void run() { doStuff(); } }).start();
第12题:
0
1
2
3
第13题:
下面程序段的输出结果是 class Test{ public static void main(String args[]){ MyThread t=new MyThread(); t.displayOutput("t has been created)); t.start(); } } class MyThread extends Thread{ public void displayOutput(String s){ System.out.println(s); } public void run(){ displayOutput(t is running."); } }
A.t has been created.
B.t has been created. t is running.
C.t is running.
D.编译出错
第14题:
下面程序段的输出结果是 classTest{ public static void main(Stringargs[]){ MyThread t=new MyThread(); t.displayOutput(”t has been createD) ”); t.start(); } } Class MyThread extends Thread{ public void displayOutput(Strings){ System.out.println(S); } public void run(){ displayOutput(”t is running.”); } }
A.thas been created. t is running.
B.thas been created
C.t is running.
D.编译出错
第15题:
下面程序段的输出结果是 class Test{ public static void main(String args[]){ MyThread t=new MyThread(); t.displayOutput("t has been createD) "; t.start(); } } class MyThread extends Thread{ public void displayOutput(String s){ System.out.println(s); } public void nm(){ displayOutput("t is running."); }
A.t has been created. t is running.
B.t has been created.
C.t is running.
D.编译出错
第16题:
下列程序创建了一个线程并运行,请在下划线处填入正确代码。
public class Try extends Thread{
public static void main(String args[]){
Threadt=new Try();
【 】;
}
public void run(){
System.out.println(“Try!”);
}
}
第17题:
class MyThread extends Thread { public void run() { System.out.println(“AAA”); } public void run(Runnable r) { System.out.println(“BBB”); } public static void main(String[] args) { new Thread(new MyThread()).start(); } } What is the result?()
第18题:
下列代码正确的是哪项?()
第19题:
Which two code fragments will execute the method doStuff() in a separate thread?()
第20题:
public class Session implements Runnable, Clonable{ public void run ();public Object clone () ; }
public class Session extends Runnable, Cloneable { public void run() {/*dosomething*/} public Object clone() {/*make a copy*/} }
public abstract class Session implements Runnable, Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
public class Session implements Runnable, implements Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
第21题:
hi
hi hi
编译失败
代码运行,但无输出结果
第22题:
A done
B done
A done B done
B done A done
There is no exception that the application will print anything.
The application outputs “A done” and “B done”, in no guaranteed order.
第23题:
hi hi
hi
编译失败
运行时异常被抛出
第24题:
AAA
BBB
Compilation fails.
The code runs with no output.