Sun Certified Java Developer Question:
Download Questions PDF

Explain 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 class 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

Answer:

B:The output could be 6-1 6-2 5-1 5-2

Download Sun Certification Interview Questions And Answers PDF

Previous QuestionNext Question
Explain Given:
21. class Money {
22. private String country = "Canada";
23. public String getC() { return country; }
24. }
25. class Yen extends Money {
26. public String getC() { return super.country; }
27. }
28. public class Euro extends Money {
29. public String getC(int x) { return super.getC(); }
30. public static void main(String[] args) {
31. System.out.print(new Yen().getC() + " " + new Euro().getC());
32. }
33. }
What is the result?
A. Canada
B. null Canada
C. Canada null
D. Canada Canada
E. Compilation fails due to an error on line 26.
F. Compilation fails due to an error on line 29.
Explain What is the result of mounting a file system with thenoatimeoption enabled? A.It enables the UFS logging B.It disables the update of file access times C.It prevents the creation of files larger than 2Gbytes D.It prevents the user from updating the file modification times