在程序的下划线处填入的选项是________。 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 RunnableB.extends ThreadC.implements ThreadD.extends Runnable

在程序的下划线处填入的选项是________。 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


参考答案和解析
A

相关考题:

下列程序段的输出结果是【 】。public class Test {void printValue(int m) {do {System.out.println("The value is"+m);}while (--m>10);}public static void main (String args[]) {int i=10;Test t= new Test();t.printValue(i);}}

如下程序的输出结果是( )。 public class Test { void printValue(int m) { do { System.out.println("The value is"+m); } while( --m>10) } public static void main(String args[]) { int i=10; Test t=new Test(); t.printValue(i); } }A.The value is 8B.The value is 9C.The value is 10D.The value is 11

( 24 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]){Thread t1 = new Thread ( new Hello ()):Thread t2 = new Thread ( new Hello ()):t l .start ():t2.start ();}}class Hello implements Runnable {int i ;public void run (){while ( true ) {System.out.println ( "Hello"+i++ ) ;if ( i=5 ) break :}}}该程序创建线程使用的方法是()A )继承 Thread 类B )实现 Runnable 接口C ) t l.start ()D ) t2.start ()

( 28 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]) throws Exception {int i=0;Hello t = new Hello ();___________;whlle ( true ){System.out.println ( "Good Morning"+i++ ) ;if ( i=2 && t.isAlive ()){System.out.println ( "Main waiting for Hello ! ” );tjoin () ; // 等待 t 运行结束}if ( i==5 ) break :}}}class Hello extends Thread {int i ;public void run ()笼while ( true ){System.out.println ( "Hello"+i++ ) ;if ( i=5 ) break ;}}}为使该程序正确执行,下划线处的语句应是A ) t.sleep ()B ) t.yieldn ()C ) t.interrupt ()D ) t.start ()

下面程序的功能是创建一个显示5个“Hello!”的线程并启动运行。请将程序补充完整。public class ThreadTest extends Thread {public static void main(String args[]) {ThreadTest t=new ______;t.start();}public void run() {int i=0;while(true) {System.out.println("Hello!");if(i++==4)break;}}}

请在下划线处填入代码,是程序正常运行并且输出 “ Hello! ”Class Test 【 15 】 {Public static void main (String[] arge){Test t = new Test();t.start();}Public void run(){System.out.println( “ Hello! ” );}

请阅读下面程序 public class ThreadTest{ public static void main(String args[]) ( Thread t1=new Thread(new Hello()); Thread t2=new Thread(new Hello()); t1.start(); t2.start(); } } class Hello implements Runnable { int i; public void run() { while(true) { System.out.prinfin("Hello"+i++); if(i=5) break; } } } 该程序创建线程使用的方法是A.继承Thread类B.实现Runnable接口C.t1.start()D.t2.start()

请阅读下面程序 public class ThreadTest { public static void main(String args[]) throws Exception{ int i=0; Hello t=new Hello(); while(true) { System.out.println("Good Moming"+i++); if (i==2 t.isAlive()) { System. out.println("Main waiting for Hello!"); t.join(); //等待t运行结束 } if(i==5) break;} } } class Hello extends Thread { int i; public void run() { while(true){ System.out.println("Hello"+i++); if (i==5) break;}}} 为使该程序正确执行,下划线处的语句应是A.t.sleep()B.t.yield()C.t.interrupt()D.t.start()

下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出

请阅读下面程序 public class ThreadTest{ public static void main(String args[])throws Ex- ception{ int i=0; Hello t=new Hello; ; while(true){ System.Out.println("Good Morning"+i++): if(i= =2t.isAlive){ System.out.println("Main waiting for Hel- lo!"); join;//等待t运行结束 } if(i= =5)break;} } } class Hello extends Thread{ int l; public void run{ while(true)( System.Out.println("Hell0"+i++); if(i= =5)break;)))A.t.sleepB.t.yieldC.t.interruptD.t.start

下列代码的执行结果是public class Test{ public int aMethod(){ static int i=0; i++; System.out.println(i); } public static void main(String args[]){ Test test= new Test(); test. aMethod(); }}A.编译错误B.0C.1D.运行成功,但不输出

阅读下面代码 public class Test implements Runnable { public void run(Thread t) { System.out.println("Running"); } public static void main(String[] args) { Thread tt=new Thread(new Test()); tt.start(); } } 代码运行的结果是A.将抛出一个异常B.没有输出并正常结束C.输出“Running”并正常结束D.程序第2行将出现一个编译错误

下列程序的执行结果是______。 class T5 implements Runnable { public void run() { int i = 0; While(i<2) { Thread t = Thread.currentThread(); System.out.println(i + t.getName()); i++ } } } public class Testl6 { public static void main(String[] args) { Thread t1 = new Thread(new T5(), "TS"); t1.start (); Thread t = Thread.currentThread(); for(int i = 0; i<3; i++) { System.out.println(I + t.getName()); if(i == 1 t1.isAlive()) t.yield(); } } }A.Omain lmam 0T5 1T5 2mainB.Omain lmam 2mainC.Omain lmain 2main 0T5 1T5D.Omain lmain 0T5 1T5

阅读下面程序 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 ThreadB.extends RunnableC.implements RunnableD.extends Thread

阅读下面程序 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();

在下面程序的下画线处应填入的选项是 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 RunnableB.extends ThreadC.implements ThreadD.extends Runnable

在程序的下画线处应填入的选项是( )。 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;i5;i++){ System.out.println("i="+i); } } }A.implements RunnableB.extends ThreadC.implements ThreadD.extends Runnable

下列程序的功能是在监控台上每隔一秒钟显示一个字符串”Hello!”,能够填写在程序中下画线位置,使程序完整并能正确运行的语句是( )。 public class Test implements Runnable{ public static void main(String args[]){ Test t=new Test: Threadt t=new Thread(t); tt.start: } public void run{ for(;;){ try{ ; }catch(e){} System.out.println("Hello"); } } }A.sleep(1000)B.t.sleep(1000)InterruptedExceptionInterruptedExceptionC.Thread.sleep(1000)D.Thread.sleep(1000)RuntimeExceptionInterruptedException

下列程序的功能是在监控台上每隔一秒钟显示一个字符串“Hello!”,能够填写在程序中下划线位置,使程序完整并能正确运行的语句是public class Test implements Runnable{ public static void main(String args[]){ Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run(){ for(;;){ try{ ; }catch( e){} System.out.println("Hello"); } } }A.sleep(1000)B.t.sleep(1000)InteruptedException InterruptedExceptionC.Thread.sleep(1000)D.Thread.sleep(1000)RuntimeException InterruptedException

下列代码的执行结果是( )。public class Test{public int aMethod( ){static int i=0;i++;System.out.println(i):}public static void main (String args[]){Trest test=new Test ( );test aMethod( ):}}A.编译错误B.0C.1D.运行成功,但不输出B.C.D.

阅读下面程序 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 ThreadB.extends RunnableC.implements RunnableD.extends Thread

阅读下面程序 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();

请阅读下面程序,说明该程序创建线程使用的方法是( )。 public class ThreadTest { public static void main(String args[]) { Thread tl=new Thread(new HolloWorld); Thread t2=new Thread(new HolloWorld); tl.start; t2.Start; } } class HolloWorld implements Runnable { int i; public void run { while(true) { System.out.println("HolloWorld"+i++); if(i= =5)break; } } }A.继承Thread类B.实现Runnable接口C.tl.startD.t2.start

下列代码的执行结果是 public class Test{ public int aMethod( ) { static int i=0; i+ +; System.out.println(i); } public static void main(String args[ ]){ Test test = new Test( ); test.aMethod( ); } }A.编译错误B.0C.1D.运行成功,但不输出

( 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;i5;i++){system.out.println( " i= " +i);}}}A ) implements RunnableB ) extends ThreadC ) implements ThreadD ) extends Runnable

public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()  A、 0B、 1C、 2D、 Compilation fails.

单选题public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()A 0B 1C 2D Compilation fails.

单选题public class test(    public int aMethod()[   static int i=0;   i++;   return I;   )    public static void main (String args){   test test = new test();    test.aMethod();   int j = test.aMethod();   System.out.printIn(j);   ]  }   What is the result?()A Compilation will fail.B Compilation will succeed and the program will print “0”C Compilation will succeed and the program will print “1”D Compilation will succeed and the program will print “2”