Regarding Garbage Collection?
-
1.class Snoochy { 2.Boochy booch; 3.public Snoochy() { booch = new Boochy(this); } 4.} 5.class Boochy { 6.Snoochy snooch; 7.public Boochy(Snoochy s) { snooch = s; } 8.} And the statements 9.public static void main(String[] args) { 10.Snoochy snoog = new Snoochy(); 11.snoog = null; // more code here } Which statement is true about the objects referenced by snoog, snooch, and booch immediately after line 23 executes? A. None of these objects are eligible for garbage collection. B. Only the object referenced by booch is eligible for garbage collection. C. Only the object referenced by snoog is eligible for garbage collection. D. Only the object referenced by snooch is eligible for garbage collection. E. The objects referenced by snooch and booch are eligible for garbage collection. i thought the answer is C but the answer is E.can anyone explain hw is it possible ?? coz in line 11 we have assigned snoog=null.then it should be ready for garbage collection but why its not counted?? pls explain in detail
-
Answer:
the two classes reference each other. So.. when snoog is created, you also get a booch and a snooch. when you set snoog = null, booch and snooch are eligible for GC,
Krithika at Yahoo! Answers Visit the source
Other answers
its E cus...after line 7 snooch an booch arnt recalled/referenced, hence its ready for garage collection. however my explanation might be wrong as im new to java, and this is how i understand the garbage collection works
Ronnie Bullard
Related Q & A:
- How to Set Specific Site Collection as SharePoint Search Scope using C#?Best solution by SharePoint
- Are strings garbage collected?Best solution by Stack Overflow
- How to efficiently aggregate several collections into one collection?Best solution by Stack Overflow
- Which country produces the most garbage in the world?Best solution by sites.google.com
- How do you become a garbage man?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.