This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one 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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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.
 
Consider Paul's rocket mass heater.
 
subject: SCJP