aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "garbage collection" Watch "garbage collection" New topic
Author

garbage collection

Suhita Reddy
Ranch Hand

Joined: Jun 09, 2006
Posts: 60
Hi,
when b1 is eligible 4 garbage collection

[ July 10, 2006: Message edited by: Barry Gaunt ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Please, please use tags around your code. It makes code so much easier to read.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
when b1 is eligible 4 garbage collection


What "4" do you mean? Line 4?

Ha! We have a question here, not a statement.

"When is the object referenced by variable b1 eligible for garbage collection?"

You had me confused there with all this pseudo-speak.

[ July 10, 2006: Message edited by: Barry Gaunt ]
[ July 10, 2006: Message edited by: Barry Gaunt ]
Suhita Reddy
Ranch Hand

Joined: Jun 09, 2006
Posts: 60
yes, line4
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
My answer is just after the line numbered //2, there is no reference to the Byte("127") object at that point.
Mike Noel
Ranch Hand

Joined: Dec 15, 2005
Posts: 108
Am I understanding correct? The original poster thinks that Byte("127") isn't available for GC until after line 4? It seems pretty clear that after line 2 that object is available, just as Barry said.

What is the reasoning you are using that makes you think it would be line 4? Maybe I'm missing something here.

_M_


Mike Noel
Suhita Reddy
Ranch Hand

Joined: Jun 09, 2006
Posts: 60
i also think in the same way.but they gave answer as at b1=null it is going to garbage collected
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Byte Object will be eligible for GC after the execution of line 2. If you comment line b2[1] = b1; then same Byte object will be eligible for GC after the execution of line 1.

Naseem


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
Amit Batra
Ranch Hand

Joined: Mar 04, 2006
Posts: 361
but they gave answer as at b1=null it is going to garbage collected


Who is saying this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: garbage collection