Win a copy of Spring Boot in Practice this week in the Spring forum!

Rob Kiu

+ Follow
since Feb 02, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rob Kiu

Hi Satish,
Thanks for taking the time to read my long post and reply.
Appreciate it very much !!.
It's certainly helpful
Questions about the actual SCJP testing software interface (hope these kind of questions are allowed and not breaking any NDA).
1. Does the remaining number of unanswered questions appear on the main screen as you answer the questions?
This will help if eg I'm going to do a 1st pass and pick those questions that are easy & answer them straight away. Only problem is you never know how many of these, so if at the end of 1st pass, I can see the number of question remaining and the time remaining (which I believe is shown), can gauge whether I am ahead /behind /on schedule
2. Is there a review screen showing all questions you have answered, unanswered or mark for review and you can click to go to any question straight away to check your answer?
3. Does the testing software has to connect to Internet/some server to retrieve the questions as the exam progress or just locally on the PC?. Anyone encountered say testing PC or OS problem in middle of exam. Then how to continue???
Tried some mock exam and while the clock is running down, the question takes long time to show up, so I was sitting there waiting and losing time duh !!-sorry abt this one.
4. Which mock exam is closest to the style of the real exam, eg those from Marcus Green or K & B book CD or the e-Practice exam from Sun website?
or others?
ePractice Certification Exam for the Sun[tm] Certified Programmer for the Java[tm] 2 Platform 1.4

Taking the exam soon...just want to be sure and not let any technicalities affect how I'll do for the exam. The exam is tough enough already...
TIA for any help & comment
Hi Dhanashree,
You can also get the API as a or winhelp file...then you can browse the API while off-line (from Net) or say on a plane.
The link is:
Java SDK 1.4.2 in help files format

Dear Bijesh, Sindhu,
Thanks for clearing that up. Look up the API to confirm, yes indeed Thread has a public void run method, whereas I thought only Runnable has the run method, so the code I quoted works!
From 1.4.2 API

public void run()
If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.
Subclasses of Thread should override this method.

You code is clear to me. Thanks very much ! Didn't realise result of method add(element) is a boolean and thus can be used to check.
So now I understand & confirm for myself: Set will neglect (or some mock exam use the term reject) duplicate elements while Map will overwrite duplicate keys with latest one.
p.s. Narasimha, hope u don't mind, modify your codes below to form more easily understood by me...hope it'll be of help 2 others as well.

Hi everyone,
Code below compiled, executes and prints out nothing. My question is why; is OK when it was not overridden and class Bground does not implements Runnable. Thought it'll give compile error eg: if we call a method say b.test(); but did not define the method signature in the class eg void test(){};
Appreciate any help, thanks !!
From Marcus Green Mock : Question Bank Id:106, code added:b.test(); & comments
Hi All,
What is the behaviour of Set when dealing with duplicate values, eg we use method add("One") then add("One") to say a HashSet, does it overwrite the earlier "One" with latest value of "One" or reject the latest "One"?
For comparison, below code shows for Map which does not allow duplicate key, the behavior is overwrite the earlier key, so output is Two for all Map classes.
I am not sure how to write code for Set to verify its behavior. Anyone can help with some code sample for Set similar to verify Map?
Thanks very much,
credits: original code from Marcus Green 1.4 Mock Question Bank ID 250,
modified with comments Satish There are two types, one you left without answering - "incomplete" and others you mark them for further review. Those which are "Incomplete" will not be considered and on the other hand those which are marked for further review also may not be considered. Because you may not answer the question and mark it, or you may answer the quetion and mark it to make sure later. So I think both which are "marked" and those which are incomplete will not be considered. This is my assumption only.

Hi, anyone who has taken the exam can confirm those you have put down an answer but marked it for later review will be scored? I agree those without answer or incomplete is marked wrong. But those with answer should be scored right?, even if you put a mark to review it. Otherwise, it will be troublesome to remove all the review ticks. When I do mock exams, I like to mark quite a large no. of questions for later review although I have put down a more or less final answer.
Any info will be helpful. Thanks !!
Dear Bojan & Corey,
Thanks a lot, your explanations certainly helps.
Got a bit confused by i1.other(i3); i2.other(i1); i3.other(i2); i4.other(i4);part and how they end up referring to each other, luckily not by the NOT eligible part. Bojan cleared it up with his "ring like structure" explanation.
Will try more GC questions, seems my weak area.
Have problem understanding the answer to question below Anyone can give a line by line explanation how i1, i2, i3 ends up referring to each other? What abt i4?
Your help most appreciated.
Q from Dan Chisholm single topic exam on GC.
Question 4
class I {
private I other;
public void other(I i) {other = i;}
class J {
private void m1() {
I i1 = new I(), i2 = new I();
I i3 = new I(), i4 = new I();
i1.other(i3); i2.other(i1);
i3.other(i2); i4.other(i4);
public static void main (String[] args) {
new J().m1();
Which object is not eligible for garbage collection after method m1 returns? Ans: g. None of the above
Please note that this question asks which object is NOT eligible for garbage collection after method m1 returns. The objects referenced by i1, i2 and i3 form a ring such that each object is referenced by another. Even so, nothing outside of method J.m1 references any of those objects. When method J.m1 returns, the ring becomes an island of isolated objects that are not reachable by any part of the user program. A key point to remember is that an object that is referenced by another object can be eligible for garbage collection if the two objects form an island of isolated objects.
Dear Sarasvathi,
SCJP Sun Certified Java Programmer exam. You have to get SCJP (Exam CX-310-035 for SDK1.4 (that's the current Java release, until Tiger (SDK1.5) comes around, before you are allowed to attempt the SCJD Sun Certified Java Developer cert(assignment (write a Java progam) and essay based exam).
Hope these helps for starters...for more, check out the various FAQs, eg:
Dear Vineela,
Thanks a whole bunch for ur explanation. Helps a lot!! Feel I can tackle such gc questions now without problem.
Hi Tom,
Double or should I say triple eureka indeed !!
Your explanation is super, the Q and A seems crystal clear to me now.
Thanks very much!

My own thinking on the Q, correct me if I am wrong, please...
12. X3 x2 = new X3(); //object new X3()-1 reference to x2
13. X3 x3 = new X3(); //object new X3()-2 reference to x3
14. X3 x5 = x3; //x5 refer to x3 refer to new X3()-2 from L13.
15. x3 = x2; //x3 refer to x2 refer to new X3()-1 from L12.
16. X3 x4 = x3; //x4 refer to x3 refer to new X3()-1 from L15.
17. x2 = null; //set x2 ref variable to null,
//new X3()-1 lost reference, eligible for GC
18. // insert code
A. x3 = null; //if x3 ref variable set to null, cause new X3()-1
//lost reference, from L15 (same effect as L17)
B. x4 = null; //if x4 ref variable set to null, cause new X3()-1
//lost reference, from L16 (same effect as L17)

C. x5 = null; //if x5 ref variable set to null, cause new X3()-2
//lost reference, (from L14)
D. x3 = x4; //x3 refer to x4 refer to new X3()-1 also (L16)
E. x5 = x4; //x5 refer to x4 cause x3 & thus new X3()-2 to lost
//reference (L14)
Sounds convoluted, no wonder I am confused...
Anyone can explain above more clearly or simply?
Hi everyone,
Don't quite understand the explanation of the answer. Appreciate if anyone can help explain the answers in a little more detail, eg what happen as each line of the code execute....

Self Test Chap 7, Q14 K&B's book
12. X3 x2 = new X3();
13. X3 x3 = new X3();
14. X3 x5 = x3;
15. x3 = x2;
16. X3 x4 = x3;
17. x2 = null;
18. // insert code
Q: What two lines of code, inserted independently at line 18, will make an object eligible for garbage collection? (Choose two.)
A. x3 = null;
B. x4 = null;
C. x5 = null;
D. x3 = x4;
E. x5 = x4;
Answer: C and E.
Explanation: By the time line 18 is reached, x2 is null, x3 and x4 refer to the object created in line 12, and x5 refers to the object created in line 13. Any kind of redirection of x5 will leave the second object without a reference.
A, B, and D are incorrect because the first object has two references; changing one of the references will not cause the first object to become unreachable.
Thks a million for your help !!