mr.cazurro greenlins

Greenhorn
+ Follow
since Jan 17, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by mr.cazurro greenlins

I know c2 is not null, but c3 is null, as c1.

so everything that applies for c1, applies for c3 so 4 objects are eliglible for garbage collector...

class CardBoard {
Short story = 200;
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 it reaches //do Stuff c1 and c3 are null, so 4 objects are eligible for GC and there is no test option for this...

am I lossing anything???
inspecting test chapter 3 question 11:

class Alpha{
static Beta b1;
Beta b2;
}

When it does

Alpha a1=new Alpha();
a1=null;

when it assigns a1=null, it implicitly assigns all a1's members variables to null too, so a1.b1 and a1.b2 loss their references