| Author |
Passed SCJP 1.4 98%
|
Bala Rathakrishnan
Greenhorn
Joined: Sep 03, 2004
Posts: 8
|
|
Completed my SCJP today. I scored 98%. Missed out a question on Threads. I used Kathy Sierra's book and Kaled A Mugals book. Took 5 mock exams from CD that came along with the books. Some sample questions class B { } public class A { private B myB= new B(); void killIt(B b) { b=null; } void doIt() { killIt(myB); } } Select 2 correct Answers A. There are no Object eligible for Garbage collection B. Explicitly setting myB to null will make it eligible for Garbage collection C. Private instances of B will be eligible for Garbage collection when instances of B are garbage collected D. 1 Object eligible for Garbage collection Answer : B & C (had a dilemma whether to choose A or B) Question 2: class ThreadImplementer implements Runnable { public void run() { System.out.println("Running"); } public void start() { System.out.println("Starting"); } } public class myThread extends Thread { public void run() { System.out.println("Running in my Thread"); } public static void main(String[] args) { (new Thread(new ThreadImplementer())).start(); } } What will be the output A. Running in my Thread B. Starting C. Running D. Compilation error E. RunTime Exception I selected B. This might be the question where I lost it. I think I reproduced the question to my knowledge. Question 3 11. void doIt() { 10. A a= new A(); 11. B b= new B(); 12. b.doSomething(a); 13. a = null; 14. b = null; 15. } When will the object created at line 10 be eligible for Garbage Collection A. After line 13 B. After line 14 C. After exiting doIt() method D. Cannot be determined Answer. D Question 4 class myThread extends Thread { int a; public void run() { for (int i=0;i<10;i++) { if ((i % 2) ==0) a = 10; else a= 5; } a=10; } } public class TestIt { public static void main(String[] args) { myThread a= new myThread(); a.start(); // Here System.out.println("int value "+ a.a); } } What should be added at the place //Here to produce the output "int value 10" A. a.wait(); B. a.run(); C. Thread.sleep(1000); D. a.join(); Answer : D
|
Bala<br />SCJP 1.4 98%<br />SCBCD 97%<br />SCWCD 91%
|
 |
 |
|
|
subject: Passed SCJP 1.4 98%
|
|
|