单选题public class Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes and prints “running”.D The code executes and prints “runningrunning”.E The code executes and prints “runningrunningrunning”.

单选题
public class Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?()
A

 Compilation fails.

B

 An exception is thrown at runtime.

C

 The code executes and prints “running”.

D

 The code executes and prints “runningrunning”.

E

 The code executes and prints “runningrunningrunning”.


参考解析

解析: 暂无解析

相关考题:

通过实现Rmmable接口创建线程,请在下面横线处填写代码完成此程序。public class ThreadTest{public static void main(String args []){Thread testObj1 = new Thread (new Hello ());Thread testObj2 = new Thread (new Hello ());testObj 2.start ( );}}class Hello implements Runnable{int j;public void run(){System.out.println("Hello" + j ++);}}

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

( 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 Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes and prints “running”.D、 The code executes and prints “runningrunning”.E、 The code executes and prints “runningrunningrunning”.

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?()  A、 AAAB、 BBBC、 Compilation fails.D、 The code runs with no output.

public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints “bar”.D、 The code executes normally, but nothing prints.

public class Foo implements Runnable (  public void run (Thread t) {  system.out.printIn(“Running.”);  }  public static void main (String[] args)  {  new thread (new Foo()).start();  } )   What is the result?()      A、 An exception is thrown.B、 The program exists without printing anything.C、 An error at line 1 causes compilation to fail.D、 An error at line 2 causes the compilation to fail.E、 “Running” is printed and the program exits.

现有:   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、 运行时异常被抛出

public class TestOne implements Runnable {  public static void main (String[] args) throws Exception {  Thread t = new Thread(new TestOne());  t.start();  System.out.print(”Started”);  t.join();  System.out.print(”Complete”);  }  public void run() {  for (int i= 0; i 4; i++) {   System.out.print(i);  }  }  }  What can be a result?()A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes and prints “StartedComplete”.D、 The code executes and prints “StartedComplete0123”.E、 The code executes and prints “Started0l23Complete”.

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、代码运行,但无输出结果

现有:  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():     }          结果为:()      A、 hi hiB、 hiC、编译失败D、运行时异常被抛出

class Order implements Runnable {    public void run ()  {  try { Thread.sleep (2000) ;  } catch (Exception e)    System.out.print("in") ;  public static void main (String [] args)  {    Thread t = new Thread (new Order ()) ;    t.start () ;  System.out.print ("pre ") ;  try { t.join () ;  } catch (Exception e)  { }    System.out.print ("post") ;   可产生哪两项结果?()  A、 pre in postB、 pre inC、 in post preD、 in pre postE、 pre post in

public class Threads4 {  public static void main (String[] args) {  new Threads4().go();  }  public void go() {  Runnable r = new Runnable() { public void run() {  System.out.print(”foo”);  }  };  Thread t = new Thread(r);  t.start();  t.start();  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The code executes normally and prints „foo”.D、 The code executes normally, but nothing is printed.

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.

单选题public class Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes and prints “running”.D The code executes and prints “runningrunning”.E The code executes and prints “runningrunningrunning”.

单选题class Work implements Runnable {  Thread other;   Work(Thread other) { this.other = other; }  public void run() {  try { other.join(); } catch (Exception e) { }  System.out.print("after join ");  } }  class Launch {  public static void main(String [] args) {  new Thread(new Work(Thread.currentThread())).start();  System.out.print("after start ");  } }  结果为:()Aafter joinBafter startCafter join after startDafter start after join

单选题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?()A AAAB BBBC Compilation fails.D The code runs with no output.

单选题public class TestOne implements Runnable {  public static void main (String[] args) throws Exception {  Thread t = new Thread(new TestOne());  t.start();  System.out.print(”Started”);  t.join();  System.out.print(”Complete”);  }  public void run() {  for (int i= 0; i 4; i++) {   System.out.print(i);  }  }  }  What can be a result?()A Compilation fails.B An exception is thrown at runtime.C The code executes and prints “StartedComplete”.D The code executes and prints “StartedComplete0123”.E The code executes and prints “Started0l23Complete”.

单选题public class Threads4 {  public static void main (String[] args) {  new Threads4().go();  }  public void go() {  Runnable r = new Runnable() { public void run() {  System.out.print(”foo”);  }  };  Thread t = new Thread(r);  t.start();  t.start();  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes normally and prints „foo”.D The code executes normally, but nothing is printed.

单选题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行,有几个可以通过编译?()A0B1C2D3

单选题现有:  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():     }          结果为:()A hi hiB hiC编译失败D运行时异常被抛出

单选题public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?()A Compilation fails.B An exception is thrown at runtime.C The code executes normally and prints “bar”.D The code executes normally, but nothing prints.

单选题现有:  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();      }      }      结果为:()AgoB运行时异常被抛出C代码运行,无输出结果D编译失败

单选题public class Foo implements Runnable (  public void run (Thread t) {   system.out.printIn(“Running.”);   }   public static void main (String args) {   new thread (new Foo()).start();   }   )   What is the result?()A An exception is thrown.B The program exists without printing anything.C An error at line 1 causes compilation to fail.D An error at line 6 causes the compilation to fail.E “Running” is printed and the program exits.

多选题class Order implements Runnable {  public void run() {  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("in ");  }  public static void main(String [] args) {  Thread t = new Thread(new Order());  t.start();  System.out.print("pre ");  try { t.join(); } catch (Exception e) { }  System.out.print("post ");  } }  可产生哪两项结果?()Ain preBpre inCin pre postDpre in post

单选题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();  }  }  结果为:()AhiBhi 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();ACode block a.BCode block B.CCode block c.DCode block d.ECode block e.