File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SCJP" Watch "SCJP" New topic


srinibash udayasingh

Joined: Jul 09, 2007
Posts: 22
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
C. 2
D. Compilation fails.
E. It is not possible to know.
F. An exception is thrown at runtime.
� 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:
subject: SCJP
It's not a secret anymore!