阿摩線上測驗 登入

試題詳解

試卷:104年 - SCJP 201-244#99410 | 科目:OJCP(SCJP)

試卷資訊

試卷名稱:104年 - SCJP 201-244#99410

年份:104年

科目:OJCP(SCJP)

223. Given: 
11. class PingPong2{
 12. synchronized void hit(long n){ 
13. for(int i=1; i<3; i++)
 14. System.out.print(n + "-" + i + " "); 
15. } 
16. } 
17. public dass Tester implements Runnable{ 
18. static PingPong2 pp2 = new PingPong2(); 
19. public static void main(String[] args){
 20. new Thread(new Tester()).start(); 
21. new Thread(new Tester()).start(); 
22. }
 23. public void run(){pp2.hit(Thread.currentThread.getId());} 
24. }
 Which statement is true?
(A) The output could be 5-1 6-1 6-2 5-2
(B) The output could be 6-1 6-2 5-1 5-2
(C) The output could be 6-1 5-2 6-2 5-1
(D) The output could be 6-1 6-2 5-1 7-1
正確答案:登入後查看