반응형
자격증/OCJP_ExamB2018. 7. 9. 20:45QUESTION 16

QUESTION 16 Given: 1. public class TestFive { 2. private int x; 3. public void foo() { 4. int current = x; 5. x = current + 1; 6. } 7. public void go() { 8. for(int i = 0; i < 5; i++) { 9. new Thread() { 10. public void run() { 11. foo(); 12. System.out.print(x + ", "); 13. } }.start(); 14. } } 15. } Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ? (Choose two.) A...

자격증/OCJP_ExamB2018. 7. 9. 20:34QUESTION 15

QUESTION 15 Which three will compile and run without exception? (Choose three.) A. private synchronized Object o; B. void go() { synchronized() { /* code here */ } C. public synchronized void go() { /* code here */ } D. private synchronized(this) void go() { /* code here */ } E. void go() { synchronized(Object.class) { /* code here */ } F. void go() { Object o = new Object(); synchronized(o) { /..

자격증/OCJP_ExamB2018. 7. 9. 19:14QUESTION 14

QUESTION 14 Given: public class TestOne implements Runnable { public static void main (String[] args) throws Exception { Thread t = new Thread(new TestOne()); t.start(); System.out.print("Started"); t.join(); System.out.print("Complete"); } public void run() { for (int i = 0; i < 4; i++) { System.out.print(i); } } } What can be a result? A. Compilation fails. B. An exception is thrown at runtime..

자격증/OCJP_ExamB2018. 7. 9. 16:46QUESTION 13

QUESTION 13 Which two statements are true? (Choose two.) A. It is possible to synchronize static methods. B. When a thread has yielded as a result of yield(), it releases its locks. C. When a thread is sleeping as a result of sleep(), it releases its locks. D. The Object.wait() method can be invoked only from a synchronized context. E. The Thread.sleep() method can be invoked only from a synchro..

자격증/OCJP_ExamB2018. 7. 9. 16:39QUESTION 12

QUESTION 12 Given: 34. HashMap props = new HashMap(); 35. props.put("key45", "some value"); 36. props.put("key12", "some other value"); 37. props.put("key39", "yet another value"); 38. Set s = props.keySet(); 39. //insert code here What, inserted at line 39, will sort the keys in the props HashMap? A. Arrays.sort(s); B. s = new TreeSet(s); C. Collections.sort(s); D. s = new SortedSet(s); Solutio..

자격증/OCJP_ExamB2018. 7. 9. 16:28QUESTION 11

QUESTION 11 Given: import java.util.*;public class Explorer1 { public static void main(String[] args) { TreeSet s = new TreeSet(); TreeSet subs = new TreeSet(); for(int i = 606; i < 613; i++) if(i%2 == 0) s.add(i); subs = (TreeSet)s.subSet(608, true, 611, true); s.add(609); System.out.println(s + " " + subs); } } What is the result? A. Compilation fails. B. An exception is thrown at runtime. C. ..

반응형
image