网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

t 是一个合法的 Thread 对象的引用,并且 t 的合法 run() 方法如下:  public void run() {  System.out.print("go ");  }  及:   t.start();  t.start();  t.run();  哪一个是结果?() 

  • A、go
  • B、go go
  • C、go go go
  • D、go 之后跟着一个异常

参考答案

更多 “ t 是一个合法的 Thread 对象的引用,并且 t 的合法 run() 方法如下:  public void run() {  System.out.print("go ");  }  及:   t.start();  t.start();  t.run();  哪一个是结果?() A、goB、go goC、go go goD、go 之后跟着一个异常” 相关考题
考题 下列程序的功能是在监控台上每隔一秒钟显示一个字符串"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); InterruptedExceptionB.t. sleep(1000); InterruptedExceptionC.Thread. sleep(1000); RuntimeExceptionD.Thread. sleep(1000); InterruptedException

考题 ( 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 ()

考题 如果使用 Thread t = new Test() 语句创建一个线程,则下列叙述正确的是A)Test 类一定要实现 Runnable 接口B)Test 类一定是 Thread 类的子类C)Test 类一定是 Runnable 的子类D)Test 类一定是继承 Thread 类并且实现 Runnable 接口

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

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

考题 t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print(go);}及:t.start();t.start();t.run();哪一个是结果?() A.goB.gogoC.gogogoD.go之后跟着一个异常

考题 现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print(go);}及:t.start();t.start();t.run();哪一个是结果?() A.gogoB.gogogoC.go之后跟着一个异常D.gogo之后跟着一个异常

考题 阅读下面代码 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行将出现一个编译错误

考题 下列程序通过设定线程优先级,抢占主线程的CPU,选择正确的语句填入横线处。 class T14 implements Runnable { private Boolean fStop - true; public void run() { while(fStop) { System.out.println(Thread.currentThread().getName() + "run"); try { Thread.sleep(l); } catch(Exception e) { e.printStackTrace(); } } } public void stopRun() { fStop = false; } } public class Testl4 { public static void main(String[] args) { T14 t14 = new T14(); Thread t1 = new Thread(ti4, "T14"); Thread t = Thread.currentThread()'; ______; Ti.start(); T14.stopRun(); System.out.println ( "stop "); } }A.setPriority(Thread. MIN_PRIORITY)B.t1 .setPriority(Thread. MIN_PRIORITY)C.t.setPfiofity(Thread. MIN_PRIORITY)D.t14.setPriority(Thread. MIN_PRIORITY)

考题 下列程序的执行结果是______。 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 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();

考题 如果使用Thread t=new Test()语句创建一个线程,则下列叙述正确的是A.Test类一定要实现Runnable接口B.Test类一定是Thread类的子类C.Test类一定是Runnable的子类D.Test类一定是继承Thread类并且实现Runnable接口

考题 当使用SomeThread t=new SomeThread( )创建-个线程时,下列叙述中正确的是( )。A.Some Thread类是包含run( )方法的任意Java类B.Some Thread类-定要实现Runnable接口C.Some Thread类是Thread类的子类D.Some Thread类是Thread类的子类并且要实现Run-nable接口

考题 下列程序创建了一个线程并运行,横线处应填入的正确代码是( )。 public class Try extends Thread{ public static void main(String args[]){ Thread t=new Try; ; } public void runf System.out.println(”Try!"); } }A.t.startB.t.classC.t.threadD.t.static

考题 下列程序的功能是在监控台上每隔一秒钟显示一个字符串”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

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

考题 下列程序的输出结果是______。 class T44 implements Runnable { public void run() { System.out.print in (Thread.currentThread ( ).getName ( ) + "运行" ); } } public class ex44 { public static void main(String[] args) { Thread t1 = new Thread(new T44(), "t1"); Thread t2 = new Thread(new T44 () , "t2"); t1 .setPriority(Thread. MAX_PRIORITY); t2.setPriority(Thread.MIN_PRIORITY); t2. start (); t1 .start (); } }A.t1 运行 t2 运行B.t2 运行 t1 运行C.t1 运行 t1 运行D.t2 运行 t2 运行

考题 请阅读下面程序,说明该程序创建线程使用的方法是( )。 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

考题 现有:   class Thread2 implements Runnable {   void run() {   System.out.print("go ");   }   public static void main(String [] args) {   Thread2 t2 = new Thread2();   Thread t = new Thread(t2);   t.start();   }   }   结果为:()A、 goB、 编译失败C、 代码运行,无输出结果D、 运行时异常被抛出

考题 Given that t1 is a reference to a live thread, which is true?()A、The Thread.sleep() method can take t1 as an argument.B、The Object.notify() method can take t1 as an argument.C、The Thread.yield() method can take t1 as an argument.D、The Thread.setPriority() method can take t1 as an argument.E、The Object.notify() method arbitrarily chooses which thread to notify.

考题 单选题Given that t1 is a reference to a live thread, which is true?()A The Thread.sleep() method can take t1 as an argument.B The Object.notify() method can take t1 as an argument.C The Thread.yield() method can take t1 as an argument.D The Thread.setPriority() method can take t1 as an argument.E The Object.notify() method arbitrarily chooses which thread to notify.

考题 单选题t 是一个合法的 Thread 对象的引用,并且 t 的合法 run() 方法如下:  public void run() {  System.out.print("go ");  }  及:   t.start();  t.start();  t.run();  哪一个是结果?()A goB go goC go go goD go 之后跟着一个异常

考题 单选题1. class MyThread implements Runnable {  2. public void run() {  3. System.out.print("go ");  4. }  5.  6. public static void main(String [] args) {  7. // insert code here  8. t.start(); 9. }  10. }  和如下四句:  Thread t = new MyThread(); MyThread t = new MyThread();  Thread t = new Thread(new Thread());  Thread t = new Thread(new MyThread());  分别插入到第5行,有几个可以通过编译?()A 0B 1C 2D 3

考题 单选题class ThreadBoth extends Thread implements Runnable {  public void run(){ System.out.print("hi "); }  public static void main(String [] args){  Thread t1 = new ThreadBoth();   Thread t2 = new Thread(t1);  t1.run();  t2.run();  }  }  结果为:()A hiB hi hiC 编译失败D 代码运行,但无输出结果

考题 单选题Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new thread that will do the work?   CODE BLOCK a:   Runnable r = new Runnable() {   public void run() {   Work.doIt();   }   };   Thread t = new Thread(r);   t.start();   CODE BLOCK b:   Thread t = new Thread() {  public void start() {   Work.doIt();  }  };   t.start();   CODE BLOCK c:   Runnable r = new Runnable() {   public void run() {   Work.doIt();   }   };   r.start();  CODE BLOCK d:   Thread t = new Thread(new Work());   t.start();   CODE BLOCK e:   Runnable t = new Runnable() {   public void run() {   Work.doIt();   }   };   t.run();A Code block a.B Code block B.C Code block c.D Code block d.E Code block e.

考题 单选题下列程序的运行结果是(  )。class Test extends Thread{public static void main(String[] args){Thread t=new Thread();t.start();}public void run(){System.out.println("Hello");}}A 程序不能通过编译,因为没有import语句将Thread类引入B 程序不能通过编译,因为Test类没有实现Runnable接口C 程序通过编译,且运行正常,没有任何输出D 程序通过编译,且运行正常,打印出一个"Hello"

考题 单选题class Thread2 implements Runnable {   void run() {    System.out.print("go ");    }   public static void main(String [] args) {   Thread2 t2 = new Thread2();   Thread t = new Thread(t2);   t.start();    }    }    结果为:()A  goB  编译失败C  代码运行,无输出结果D  运行时异常被抛出

考题 单选题现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下:  public void run()  {  System.out.print ("go");      }      及:  t.start();      t.start();      t.run();      哪一个是结果?()A go goB go go goC go之后跟着一个异常D go go之后跟着一个异常