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

题目
单选题
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.p”相关问题
  • 第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();

    }

    }


    正确答案:

     

    错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的

    x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。

    对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可

    以通过A.x 来明确。

  • 第2题:

    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”.

    正确答案:E

  • 第3题:

    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.

    正确答案:C

  • 第4题:

    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”较早出现的可能性较大。

    正确答案:D

  • 第5题:

    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”.

    正确答案:E

  • 第6题:

    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) { }

    正确答案:D

  • 第7题:

    现有:  5.  class Order2 implements Runnable  {     6.    public void run()  {     7. for (int x- o;  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(1);  )  catch  (Exception e)  {  }
    • E、  try{Thread.sleep(100);  )  catch  (Exception  e)  {  }
    • F、  try{Thread.sleep(1000);  )  catch  (Exception  e)  { }

    正确答案:E

  • 第8题:

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


    正确答案: D
    解析: 暂无解析

  • 第9题:

    单选题
    现有:  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

    main

    B

    编译失败

    C

    main java.lang.RuntimeException: exception

    D

    代码运行,但没有输出


    正确答案: A
    解析: 暂无解析

  • 第10题:

    单选题
    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

    0

    B

    1

    C

    2

    D

    3


    正确答案: A
    解析: 暂无解析

  • 第11题:

    多选题
    public class Threads 1 {  intx=0;  public class Runner implements Runnable {  public void run() {  int current = 0;  for(int=i=0;i<4;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,


    正确答案: A,E
    解析: 暂无解析

  • 第12题:

    单选题
    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) { }


    正确答案: B
    解析: 暂无解析

  • 第13题:

    ( 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


    正确答案:A

  • 第14题:

    现有:  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、55
    • B、56
    • C、65
    • D、66

    正确答案:A

  • 第15题:

    现有:  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、main
    • B、编译失败
    • C、main java.lang.RuntimeException: exception
    • D、代码运行,但没有输出

    正确答案:C

  • 第16题:

    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、 main
    • B、 编译失败
    • C、 代码运行,但没有输出
    • D、 main java.lang.RuntimeException:exception

    正确答案:D

  • 第17题:

    public class Threads 1 {  intx=0;  public class Runner implements Runnable {  public void run() {  int current = 0;  for(int=i=0;i<4;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,

    正确答案:A,C

  • 第18题:

    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、0
    • B、1
    • C、2
    • D、3

    正确答案:C

  • 第19题:

    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.

    正确答案:B

  • 第20题:

    单选题
    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”较早出现的可能性较大。


    正确答案: B
    解析: 暂无解析

  • 第21题:

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


    正确答案: E
    解析: 暂无解析

  • 第22题:

    单选题
    现有:  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

    55

    B

    56

    C

    65

    D

    66


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    现有:  5.  class Order2 implements Runnable  {     6.    public void run()  {     7. for (int x- o;  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(1);  )  catch  (Exception e)  {  }

    E

      try{Thread.sleep(100);  )  catch  (Exception  e)  {  }

    F

      try{Thread.sleep(1000);  )  catch  (Exception  e)  { }


    正确答案: B
    解析: 暂无解析

  • 第24题:

    单选题
    现有:   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

     main

    B

     编译失败

    C

     代码运行,但没有输出

    D

     main java.lang.RuntimeException: exception


    正确答案: B
    解析: 暂无解析