Discussion :: Garbage Collections - General Questions (Q.No.3)
|Shrikant Firodiya said: (Jul 6, 2011)|
|Tell about how garbage collecter internally works?|
|Chandrabhushan said: (Apr 25, 2012)|
|The "garbage collection" that I'm talking about is the work that the drive's internal firmware does in order to consolidate the "marked as free" logical sectors into flash memory pages that can be erased so that they're ready to accept writes from the host. That happens inside the drive and is independent of what the rest of the system is doing.|
|Firdosh said: (Nov 20, 2015)|
|How garbage collection works?|
|Dipak Mehta said: (Jan 8, 2016)|
|I didn't understand can some one explain please?|
|Chaitu said: (Dec 26, 2016)|
|I didn't understand the meaning of 4, 12 &14 line on the coding.
Please explain it.
|Sathiesh said: (Feb 9, 2017)|
|As per my thought,
First, the main method called in a class.
doBar() method called by the Test class object t.
The default modifier or the public modifier class can be accessed inside its package so that the class Bar coded inside the class Test as a return type for the method doBar(). So it enters into the doBar() method from line 4, a new object created for the class Bar in doBar() method of Test class.
The object can be created by using the new keyword at line 6. Whenever the object created for a class, the constructor of the class has been called and execute the functions. It returns the object of class Bar at line 7 because the return type of doBar() is Bar. Then it returns back to line 12 and stores the returned object of class Bar from doBar() in a newBar object which is an object of class Bar.
At line 14, the value of object newBar that is the object which is created at the line 6 that has been replaced by creating a fresh (new) object. So that object which is created at the line 6 is not use after line 14.
Hence the garbage collection destroyed that object which is created at line 6 as after line 14.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.