nerdexam
Oracle

1Z0-851 · Question #29

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…

The correct answer is D. Line 8. See the full explanation below for the reasoning.

Question

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.} When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?

Options

  • ALine 5
  • BLine 6
  • CLine 7
  • DLine 8
  • ELine 9
  • FLine 10

How the community answered

(20 responses)
  • A
    10% (2)
  • D
    80% (16)
  • E
    5% (1)
  • F
    5% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice