联系我们   收藏本站   设为首页   
 
 
JAVA学习室
SCJP
    当前位置: JAVA学习室首页>> SCJP在线练习
欢迎参加SCJP在线练习
目前题库中共有728个题(id号1--728),可随机练习,也可输入试题id号练习
如试题或答案有误,请留言!!

当前试题id号=720

试题
Given the following,

 1. public class Test {
 2.  public static void main (String [] args) {
 3.    final Foo f = new Foo();
 4.   Thread t = new Thread(new Runnable() {
 5.         public void run() {
 6.        f.doStuff () ;

 7.       }
 8.   });
 9.   Thread g = new Thread() {
10.    public void run() {
11.         f.doStuff();
12.      }
13.     };
14.     t.start();
15.     g.start();
16.  }
17. }

 1. class Foo {
 2.   int x = 5;
 3.  public void doStuff ()
 4.     if (x < 10) {
 5.       // nothing to do
 6.      try {
 7.         wait();
 8.      } catch(InterruptedException ex) { }
 9.     } else {
10.      System.out.println("x is " + x++);
11.      if (x >= 10) {
12.          notify() ;
13.        }
14.     }
15.  }
16. }

What is the result?

A. The code will not compile because of an error on line 12 of class Foo.

B. The code will not compile because of an error on line 7 of class Foo.

C. The code will not compile because of an error on line 4 of class Test.

D. The code will not compile because of some other error in class Test.

E. An exception occurs at runtime.

F. x is 5 

   x is 6 

请选择: A B C D E F

  • 点击此处查看答案!!
  • 正确答案:E
    简评:没有
如果你想随机练习,请直接点"下一题",否则请输入试题id号(1--728):