阿摩線上測驗
登入
首頁
>
OJCP(SCJP)
>
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 51-100#83056
> 申論題
64
相關申論題
52 Place the code fragments in position to complete the Displayable interface.
#337040
53 Insert six modifiers into the code such that it meets all of these requirements: 1. It must be possible to create instances of Alpha and Beta from outside the packages in which they are defined. 2. When an object of type Alpha (or any potential subclass of Alpha) has been created, the instance variable alpha may never be changed. 3. The value of the instance variable alpha must always be "A" for objects of type Alpha.
#337041
65 Replace two of the Modifiers that appear in the Single class to make the code compile. Note: Three modifiers will not be used and four modifiers in the code will remain unchanged.
#337043
240. Place a Class on each method that is declared in the class.
#415658
238. Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.) (A) (B) (C) (D) (E) (F)
#415657
237. Place the code elements into the class so that the code compiles and prints "Run. Run. doIt. " in exactly that order. Note that there may be more than one correct solution.
#415656
236. Given: 1. class Computation extends Thread{ 2. 3. private int num; 4. private boolean isComplete; 5. private int result; 6. 7. public Computation(int num){this.num = num;} 8. 9. public synchronized void run(){ 10. result = num * 2; 11. isComplete = true; 12. notify(); 13. } 14. 15. public synchronized int getResult(){ 16. while(!isComplete){ 17. try{ 18. wait(); 19. }catch(InterruptedException e){} 20. } 21. return result; 22. } 23. 24.public static void main(String[] args){ 25. Computation[] computations = new Computation[4]; 26. for(int i=0; i<computations.length; i++){ 27. computations[i] = new Computation(i); 28. computations[i].start(); 29. } 30. for(Computation c : computations) 31. System.out.print(c.getResult() + " "); 32. } 33. } What is the result? (A) The code will deadlock. (B) The code may run with no output. (C) An exception is thrown at runtime. (D) The code may run with output "0 6". (E) The code may run with output "2 0 6 4". (F) The code may run with output "0 2 4 6".
#415655
228. Which three will compile and run without exception? (Choose three.) (A) private synchronized Object o; (B)(C) public synchronized void go(){/* code here */} (D) private synchronized(this) void go(){/* code here */} (E) (F)
#415654
225. Given: 10. Runnable r = new Runnable(){ 11. public void run(){ 12. try{ 13. Thread.sleep(1000); 14. }catch(InterruptedException e){ 15. System.out.println("interrupted"); 16. } 17. System.out.println("ran"); 18. } 19. }; 20. Thread t = new Thread(r); 21. t.start(); 22. System.out.println("started"); 23. t.sleep(2000): 24. System.out.println("interrupting"); 25. t.interrupt(); 26. System.out.println("ended"); Assume that sleep(n) executes in exactly n milliseconds. and all other code executes in an insignificant amount of time. Place the fragments in the output area to show the result of running this code.
#415653
220. Which factor or factors (A) It is possible for more than two threads to deadlock at once. (B) The JVM implementation guarantees that multiple threads cannot enter into a deadlocked state. (C) Deadlocked threads release once their sleep() method's sleep duration has expired. (D) Deadlocking can occur only when the wait(), notify() and notifyAll() methods are used incorrectly. (E) It is possible for a single-threaded application to deadlock if synchronized blocks are used incorrectly. (F) If a piece of code is capable of deadlocking, you cannot eliminate the possibility of deadlocking by inserting invocations of Thread.yield().
#415652
相關試卷
104年 - SCJP 201-244#99410
104年 · #99410
104年 - SCJP 51-100#99391
104年 · #99391
104年 - SCJP 151-200#99330
104年 · #99330
104年 - SCJP 1-50#41416
104年 · #41416
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 201-244#83084
#83084
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 151-200#83081
#83081
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 101-150#83070
#83070
無年度 - SCJP 6.0 認證教戰手冊第二版 SCJP 6.0 認證教戰手冊第二版 認證教戰手冊第二版_題庫 51-100#83056
#83056