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

题目
单选题
现有:  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)  { }


相似考题
更多“单选题现有:  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(str”相关问题
  • 第1题:

    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

  • 第2题:

    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”); }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }   public static void badMethod() {} }  What is the result?()  

    • A、 AC
    • B、 BD
    • C、 ACD
    • D、 ABCD
    • E、 Compilation fails.

    正确答案:C

  • 第3题:

    class Waiting implements Runnable {  boolean flag = false;  public synchronized void run() {  if (flag) {  flag = false;  System.out.print("1 ");  try { this.wait(); } catch (Exception e) { }  System.out.print("2 ");  }  else {  flag = true;  System.out.print("3 ");  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("4 ");  notify();  }  }  public static void main(String [] args) {  Waiting w = new Waiting();  new Thread(w).start();  new Thread(w).start ();  }  }  以下哪两项是正确的?() 

    • A、代码输出 1 3 4
    • B、代码输出 3 4 1
    • C、代码输出 1 2 3 4
    • D、代码不会完成

    正确答案:A,B

  • 第4题:

    2. public class Foo implements Runnable (  3. public void run (Thread t) {  4. system.out.printIn(“Running.”);  5. }  6. public static void main (String[] args)  {  7. new thread (new Foo()).start(); 8. )  9. )   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.

    正确答案:C

  • 第5题:

    1. class A implements runable (   2. int i;   3. public void run () (   4. try (   5. thread.sleep(5000);   6. i= 10;   7. ) catch(InterruptedException e) {}   8. )   9. )   10.   11. public class Test {   12. public static void main (string args) (   13. try (   14. A a = new A ();   15. Thread t = new Thread (a);  16. t.start();  17.   18. int j= a.i;   19.   20. ) catch (Exception e) {}   21. )   22. )   Which statement al line 17 will ensure that j=10 at line 19?()

    • A、 a.wait();
    • B、 t.wait();
    • C、 t.join();
    • D、 t.yield();
    • E、 t.notify();
    • F、 a.notify();
    • G、 t.interrupt();

    正确答案:C

  • 第6题:

    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 post
    • B、 pre in
    • C、 in post pre
    • D、 in pre post
    • E、 pre post in

    正确答案:A,D

  • 第7题:

    现有   1. class Calc {  2.  public static void main(String [] args) {   3.    try {  4.         int x = Integer.parselnt ("42a") ;   5.     //insert code here  6.         System.out.print ("oops");   7.    }   8.   }   9. }   下面哪两行分别插入到第五行,会导致输 "oops" ? () 

    • A、 } catch (IllegalArgumentException e) {
    • B、 } catch (IllegalStateException c) {
    • C、 } catch (NumbelFormatException n) {
    • D、 } catch (ClassCastException c) {

    正确答案:A,C

  • 第8题:

    单选题
    1. public class X {  2. public static void main (String[]args)   {  3. int [] a = new int [1]  4. modify(a);  5. System.out.printIn(a[0]);  6. }  7.    8. public static void modify (int[] a)  {  9.   a[0] ++;  10.    } 11. }       What is the result?()
    A

     The program runs and prints “0”

    B

     The program runs and prints “1”

    C

     The program runs but aborts with an exception.

    D

     An error “possible undefined variable” at line 4 causes compilation to fail.

    E

     An error “possible undefined variable” at line 9 causes compilation to fail.


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

  • 第9题:

    单选题
    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
    解析: 暂无解析

  • 第10题:

    单选题
    1. class A implements runable (   2. int i;   3. public void run () (   4. try (   5. thread.sleep(5000);   6. i= 10;   7. ) catch(InterruptedException e) {}   8. )   9. )   10.   11. public class Test {   12. public static void main (string args) (   13. try (   14. A a = new A ();   15. Thread t = new Thread (a);  16. t.start();  17.   18. int j= a.i;   19.   20. ) catch (Exception e) {}   21. )   22. )   Which statement al line 17 will ensure that j=10 at line 19?()
    A

     a.wait();

    B

     t.wait();

    C

     t.join();

    D

     t.yield();

    E

     t.notify();

    F

     a.notify();

    G

     t.interrupt();


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

  • 第11题:

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

    in pre

    B

    pre in

    C

    in pre post

    D

    pre in post


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

  • 第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题:

    1. public class Test { 2. public static String output =””; 3.  4. public static void foo(int i) { 5. try { 6. if(i==1) { 7. throw new Exception(); 8. } 9. output += “1”; 10. } 11. catch(Exception e) { 12. output += “2”; 13. return; 14. } 15. finally { 16. output += “3”;17. } 18. output += “4”; 19. } 20.  21. public static void main(String args[]) { 22. foo(0); 23. foo(1); 24.  25. }26. } What is the value of the variable output at line 23?()


    正确答案:13423

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

    正确答案:D

  • 第15题:

    现有:  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

  • 第16题:

    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 ");  } }  结果为:()

    • A、after join
    • B、after start
    • C、after join after start
    • D、after start after join

    正确答案:D

  • 第17题:

    现有:   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

  • 第18题:

    1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()  

    • A、 Ex0 caught
    • B、 exception caught
    • C、 Compilation fails because of an error at line 2.
    • D、 Compilation fails because of an error at line 6.

    正确答案:A

  • 第19题:

    单选题
    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 ");  } }  结果为:()
    A

    after join

    B

    after start

    C

    after join after start

    D

    after start after join


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

  • 第20题:

    单选题
    现有:  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
    解析: 暂无解析

  • 第21题:

    单选题
    2. public class Foo implements Runnable (  3. public void run (Thread t) {  4. system.out.printIn(“Running.”);  5. }  6. public static void main (String[] args)  {  7. new thread (new Foo()).start(); 8. )  9. )   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.


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

  • 第22题:

    单选题
    现有:  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
    解析: 暂无解析

  • 第23题:

    单选题
    1. class A implements Runnable (  2. int i;  3. public void run ( ) (  4. try (  5. thread.sleep(5000);  6. i= 10;  7. ) catch(InterruptedException e) {}  8. )  9. )  10.    11. public class Test {  12. public static void  main (string args[]) ( 13. try (  14. A a = new A ( );  15. Thread t = new Thread (a);  16. t.start( );  17.    18. int j= a.i;  19.    20. ) catch (Exception e) {}  21. )  22. }   Which statement al line 17 will ensure that j=10 at line 19?()
    A

     a.wait();

    B

     t.wait();

    C

     t.join();

    D

     t.yield();

    E

     t.notify();

    F

     a.notify();

    G

     t.interrupt();


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

  • 第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
    解析: 暂无解析