The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is the answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic

what is the answer

nikunj thakur
Ranch Hand

Joined: Sep 23, 2007
Posts: 47
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?




Compilation fails.

It is not possible to know.

An exception is thrown at runtime

The answer is 2 objects are eligible
C1 and Short
but c3 is also null then wy c3 is not available
marc weber

Joined: Aug 31, 2004
Posts: 11343

Originally posted by nikunj thakur:
...c3 is also null then wy c3 is not available

The answer is the same as when you posted this question a week ago.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Fu Dong Jia
Ranch Hand

Joined: May 23, 2007
Posts: 131
you can go here for some help!

who dare win!<br />SCJP5(94%)|SCWCD5(86%)|SCBCD(100%)|SCEA in progress
I agree. Here's the link:
subject: what is the answer
It's not a secret anymore!