"SCJP 1.6版考題 222" 修訂間的差異

出自 陳富國維基館
前往: 導覽搜尋
(新頁面: Given: <br>10.  public class Starter extends Thread{ <br>11.            private int x = 2; <br>12.            public...)
 
(無差異)

於 2013年3月27日 (三) 16:42 的最新修訂

Given:
10.  public class Starter extends Thread{
11.            private int x = 2;
12.            public static void main(String[] args) throws Exception{
13.                             new Starter().makeItSo();
14.             }
15.            public Starter(){
16.                              x = 5;
17.                              start();
18.            }
19.           public void makeItSo() throws Exception{
20.                              join();
21.                              x = x - 1;
22.                              System.out.println(x);
23.            }
24.           public void run(){x *= 2;}
25.           }


What is the output if the main() method is run?
  A. 4
  B. 5
  C. 8
  D. 9
  E. Compilation fails.
  F. An exception is thrown at runhime.
  G. It is impossible to determine for certain.

解答


Ans: D

解說:無