This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SCJP" Watch "SCJP" New topic
Author

SCJP

srinibash udayasingh
Greenhorn

Joined: Jul 09, 2007
Posts: 22
Given:
class CardBoard {
Short story = 5;
CardBoard go(CardBoard cb) {
cb = null;
return cb;
}
public static void main(String[] args) {
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
c1 = null;
// do Stuff
} }
When // doStuff is reached, how many objects are eligible for GC?
A. 0
B.1
C. 2
D. Compilation fails.
E. It is not possible to know.
F. An exception is thrown at runtime.
Answer:
� 3 C is correct. Only one CardBoard object (c1) is eligible, but it has an associated Short
wrapper object that is also eligible.
�˚ A, B, D, E, and F are incorrect based on the above. (Objective 7.4)


I unable to understand this qns...can anyone help me
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Hi srinibash,

you should have a look at the errata, since your example is wrong.

The corrected question:Now there are two objects eligible for garbage collection.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCJP
 
Similar Threads
Garbage collector
Garbage Collection
K&B ch-3 Ques-2
Garbage Collection from K&B book
Object eligable to GC