Results 1 to 2 of 2
- 12-06-2012, 12:05 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 5
- Rep Power
- 0
Object cleaning by Garbage Collector
Please go through this question. I am thinking of option C where o has been assigned another new Object. Can somebody explain why the answer will be line 8?
Thanks
<code>
Q: 01 Given:
1. public class GC {
2. private Object o;
3. private void doSomethingElse(Object obj) { o = obj; }
4. public void doSomething() {
5. Object o = new Object();
6. doSomethingElse(o);
7. o = new Object();
8. doSomethingElse(null);
9. o = null;
10. }
11. }
<code>
When the doSomething method is called, after which line does the Object
created in line 5 become
available for garbage collection?
A. Line 5
B. Line 6
C. Line 7
D. Line 8
E. Line 9
F. Line 10
Answer: D
- 12-06-2012, 12:28 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Garbage Collector
By giorgi in forum New To JavaReplies: 27Last Post: 05-20-2011, 10:09 AM -
about garbage collector
By sudharani in forum New To JavaReplies: 1Last Post: 04-25-2011, 11:25 AM -
How can I see the impression of the Garbage Collector?
By Zamioculcas in forum New To JavaReplies: 3Last Post: 04-01-2011, 02:34 PM -
When does the Garbage Collector pick up an object?
By nolsen01 in forum New To JavaReplies: 5Last Post: 02-27-2010, 03:32 PM -
Q about Garbage Collector
By m00nchile in forum New To JavaReplies: 4Last Post: 02-05-2010, 05:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks