This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
corret me if i wrong,
Dozens  da = new Dozens; --> 1 object
da = new Dozens(); 2 objects , one is the object dozens and the other is an array of int dz
Dozens d = new Dozens(); 2 objects , one is the object dozens and the other is an array of int dz
Yes there are two objects for garbage collection.
If you see this snippet taken from the code, here first a object of dozens was created and was referenced
by a reference d. Then da also started pointing towards the same dozens object after statement 2. Now
remember that, when you create the the dozens object another array object is also created which is called
If you observe statement 3 and 4 then you can find out now both the references which were pointing towards
the Dozen object has been set to null, so there is no way to access that object nor any alive reference to da,
so now the dozen object and array object both are eligible for garbage collection.