Sachin Gharat

Greenhorn
+ Follow
since Mar 02, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sachin Gharat

Congrats dude, i can understand how it feels now!!!
19 years ago
Congrats
19 years ago
congratulations
Sachin Gharat
SCJP 1.4
19 years ago
Hi
The question clearly states 'objects eligible for garbage' collection,
so at the end of pass 10, q will have reference Q(9), which however means objects Q(0..8) will be "eligible for garbage collection,i.e 9 objects.

Garbage collection is done by running a low priority thread(by the JVM). When we call System.gc or Runtime.gc we ask that thread to delibrately collect the garbage at that time, but this doesn't guarantee that the garbage collection will occur, because some other thread with higher priority may stop this thread for a while.

So i guess running the garbage collector before line 2 is not an issue as it cannot be forced.
Neither does it force the jvm to run the garbage collector, so in conclusion neither does it change the answer to the question.

Cheers
Sachin
SCJP 1.4