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

题目内容 (请给出正确答案)
单选题
class Order3 implements Runnable {  public static void main(String [] args) {  new Thread(new Order3()).start();  for(int x = 0; x 〈 10; x++) System.out.print("m"); }  public void run() {  for(int x = 0; x 〈 10; x++) {  //insert code here  System.out.print("r");  }  }  }  和:  当代码被编译并照此运行时产生 "before" 的输出, 当下列内容插入到代码第8行时产生"after"输出  if (x 〉 3 && x 〈 7) Thread.yield();  对比“before”的输出结果和“after”的输出结果,下面哪一项是正确的?()
A

输出字符的总数可能改变。

B

当添加额外的代码时,编译将失败。

C

在“after”输出结果中,字符“m”较早出现的可能性较小。

D

在“after”输出结果中,字符“m”较早出现的可能性较大。


参考答案

参考解析
解析: 暂无解析
更多 “单选题class Order3 implements Runnable {  public static void main(String [] args) {  new Thread(new Order3()).start();  for(int x = 0; x 〈 10; x++) System.out.print("m"); }  public void run() {  for(int x = 0; x 〈 10; x++) {  //insert code here  System.out.print("r");  }  }  }  和:  当代码被编译并照此运行时产生 "before" 的输出, 当下列内容插入到代码第8行时产生"after"输出  if (x 〉 3  x 〈 7) Thread.yield();  对比“before”的输出结果和“after”的输出结果,下面哪一项是正确的?()A 输出字符的总数可能改变。B 当添加额外的代码时,编译将失败。C 在“after”输出结果中,字符“m”较早出现的可能性较小。D 在“after”输出结果中,字符“m”较早出现的可能性较大。” 相关考题
考题 通过实现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 exl2 { public static void main(string[] args) { int n=4; int x=0; do{ System.out.print(n); }while (x++<n--); } }A.12B.432C.43D.4

考题 在下面程序的下画线处应填入的选项是 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

考题 下列程序的运行结果是______。 class A implements Runnable { int a; iht i = 2; A(int x) { a = x; } public void run() { while(i > 0) { System.out.println("线程" + a); i--; } } } public class Testl3 { public static void main(String[] args) { Thread a1 = new Thread(new A(1)); Thread a2 = new Thread(new A(2)); a1.start(); a2.start(); } }A.线程1 线程1 线程2 线程2B.线程1 线程2C.线程1 线程2 线程1 线程2D.线程1 线程1 线程1 线程1

考题 interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}

考题 ( 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 Passer f  static final int X=5;  public  static void main (String  []  args)  {      new  Passer().go (x);      System. out .print (x);      }  void go (int x)  {     System. out .print(x++);     }     结果是什么?()     A、55B、56C、65D、66

考题 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 ThreadExcept implements Runnable  {  public void run()  {  throw new RuntimeException("exception ");  }  public static void main(Stri_ng  []  args)  {  new  Thread (new  ThreadExcept()).start();  try  {  int x=Integer.parselnt (args [0]);  Thread. sleep (x);  System.out.print("main");  } catch (Exception e)  {  }  }  }  和命令行:  java ThreadExcept l000     哪一个是结果?()    A、mainB、编译失败C、main java.lang.RuntimeException: exceptionD、代码运行,但没有输出

考题 class Order3 implements Runnable {  public static void main(String [] args) {  new Thread(new Order3()).start();  for(int x = 0; x 〈 10; x++) System.out.print("m"); }  public void run() {  for(int x = 0; x 〈 10; x++) {  //insert code here  System.out.print("r");  }  }  }  和:  当代码被编译并照此运行时产生 "before" 的输出, 当下列内容插入到代码第8行时产生"after"输出  if (x 〉 3  x 〈 7) Thread.yield();  对比“before”的输出结果和“after”的输出结果,下面哪一项是正确的?() A、输出字符的总数可能改变。B、当添加额外的代码时,编译将失败。C、在“after”输出结果中,字符“m”较早出现的可能性较小。D、在“after”输出结果中,字符“m”较早出现的可能性较大。

考题 class ThreadExcept implements Runnable {   public void run() { throw new RuntimeException("exception "); }   public static void main(String [] args) {   new Thread(new ThreadExcept()).start();   try {   int x = Integer.parseInt(args[0]);   Thread.sleep(x);   System.out.print("main ");    } catch (Exception e) { }      }  }   和命令行:  java ThreadExcept 1000    哪一个是结果?()  A、 mainB、 编译失败C、 代码运行,但没有输出D、 main java.lang.RuntimeException:exception

考题 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 Threads 1 {  intx=0;  public class Runner implements Runnable {  public void run() {  int current = 0;  for(int=i=0;i4;i++){  current = x;  System.out.print(current + “, “);  x = current + 2;  }  }  }  public static void main(String[] args) {  new Threads1().go();  }  public void go() {  Runnable r1 = new Runner();  new Thread(r1).start();  new Thread(r1 ).start();  }  }  Which two are possible results?()A、 0, 2, 4, 4, 6, 8, 10, 6,B、 0, 2, 4, 6, 8, 10, 2, 4,C、 0, 2, 4, 6, 8, 10, 12, 14,D、 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,E、 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,

考题 5. class Order2 implements Runnable {  6. public void run() {  7. for(int x = 0; x 〈 4; x++) {  8. try { Thread.sleep(100); } catch (Exception e) { }  9. System.out.print("r");  10. } }  11. public static void main(String [] args) {  12. Thread t = new Thread(new Order2());  13. t.start();  14. for(int x = 0; x 〈 4; x++) {  15. // insert code here  16. System.out.print("m");  17. } } }  哪一个插入到第15行,最有可能产生输出 rmrmrmrm ?()  A、Thread.sleep(1);B、Thread.sleep(100);C、Thread.sleep(1000);D、try { Thread.sleep(100); } catch (Exception e) { }

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

考题 现有:  5.  class Order2 implements Runnable  {     6.    public void run()  {     7. for (int x- o;  x4;  x++)  {  8. try{Thread.sleep(100);  )catch  (Exception e)  {  }     9.    System.out.print("r");     10.    }  }  11.    public static void main(string  []  args)  {     12.    Thread t=new Thread(new order2());     13.    t.start();  14.    for(int x=0;  x4;  x++)  {     15.    //insert code here     16.    System.out.print("m");     17.  }  }  }  哪一个插入到第15行,最有可能产生输出 rmrmrmrm?()     A、  Thread.sleep(1);B、  Thread.sleep(100);C、  Thread.sleep(1000);D、  try{  Thread.sleep(1);  )  catch  (Exception e)  {  }E、  try{Thread.sleep(100);  )  catch  (Exception  e)  {  }F、  try{Thread.sleep(1000);  ) catch  (Exception  e)  { }

考题 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.

考题 单选题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 Order3 implements Runnable {  public static void main(String [] args) {  new Thread(new Order3()).start();  for(int x = 0; x 〈 10; x++) System.out.print("m"); }  public void run() {  for(int x = 0; x 〈 10; x++) {  //insert code here  System.out.print("r");  }  }  }  和:  当代码被编译并照此运行时产生 "before" 的输出, 当下列内容插入到代码第8行时产生"after"输出  if (x 〉 3  x 〈 7) Thread.yield();  对比“before”的输出结果和“after”的输出结果,下面哪一项是正确的?()A 输出字符的总数可能改变。B 当添加额外的代码时,编译将失败。C 在“after”输出结果中,字符“m”较早出现的可能性较小。D 在“after”输出结果中,字符“m”较早出现的可能性较大。

考题 单选题现有:  class ThreadExcept implements Runnable  {  public void run()  {  throw new RuntimeException("exception ");  }  public static void main(Stri_ng  []  args)  {  new  Thread (new  ThreadExcept()).start();  try  {  int x=Integer.parselnt (args [0]);  Thread. sleep (x);  System.out.print("main");  } catch (Exception e)  {  }  }  }  和命令行:  java ThreadExcept l000     哪一个是结果?()A mainB 编译失败C main java.lang.RuntimeException: exceptionD 代码运行,但没有输出

考题 单选题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”.

考题 单选题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 Passer f  static final int X=5;  public  static void main (String  []  args)  {      new  Passer().go (x);      System. out .print (x);      }  void go (int x)  {     System. out .print(x++);     }     结果是什么?()A 55B 56C 65D 66

考题 多选题public class Threads 1 {  intx=0;  public class Runner implements Runnable {  public void run() {  int current = 0;  for(int=i=0;i4;i++){  current = x;  System.out.print(current + “, “);  x = current + 2;  }  }  }  public static void main(String[] args) {  new Threads1().go();  }  public void go() {  Runnable r1 = new Runner();  new Thread(r1).start();  new Thread(r1 ).start();  }  }  Which two are possible results?()A0, 2, 4, 4, 6, 8, 10, 6,B0, 2, 4, 6, 8, 10, 2, 4,C0, 2, 4, 6, 8, 10, 12, 14,D0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14,E0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14,

考题 单选题现有:  5.  class Order2 implements Runnable  {     6.    public void run()  {     7. for (int x- o;  x4;  x++)  {  8. try{Thread.sleep(100);  )catch  (Exception e)  {  }     9.    System.out.print("r");     10.    }  }  11.    public static void main(string  []  args)  {     12.    Thread t=new Thread(new order2());     13.    t.start();  14.    for(int x=0;  x4;  x++)  {     15.    //insert code here     16.    System.out.print("m");     17.  }  }  }  哪一个插入到第15行,最有可能产生输出 rmrmrmrm?()A   Thread.sleep(1);B   Thread.sleep(100);C   Thread.sleep(1000);D   try{  Thread.sleep(1);  )  catch  (Exception e)  {  }E   try{Thread.sleep(100);  )  catch  (Exception  e)  {  }F   try{Thread.sleep(1000);  ) catch  (Exception  e)  { }

考题 单选题5. class Order2 implements Runnable {  6. public void run() {  7. for(int x = 0; x 〈 4; x++) {  8. try { Thread.sleep(100); } catch (Exception e) { }  9. System.out.print("r");  10. } }  11. public static void main(String [] args) {  12. Thread t = new Thread(new Order2());  13. t.start();  14. for(int x = 0; x 〈 4; x++) {  15. // insert code here  16. System.out.print("m");  17. } } }  哪一个插入到第15行,最有可能产生输出 rmrmrmrm ?()A Thread.sleep(1);B Thread.sleep(100);C Thread.sleep(1000);D try { Thread.sleep(100); } catch (Exception e) { }

考题 单选题现有:   class ThreadExcept implements Runnable {   public void run() { throw new RuntimeException("exception "); }   public static void main(String [] args) {   new Thread(new ThreadExcept()).start();   try {   int x = Integer.parseInt(args[0]);   Thread.sleep(x);   System.out.print("main ");  } catch (Exception e) { }  }   }   和命令行:  java ThreadExcept 1000   哪一个是结果?()A  mainB  编译失败C  代码运行,但没有输出D  main java.lang.RuntimeException: exception