nerdexam
Oracle

1Z0-851 · Question #236

Given: 11. public void genNumbers() { 12. ArrayList numbers = new ArrayList(); 13. for (int i = 0; i < 10; i++) { 14. int value = i * ((int) Math.random()); 15. Integer intObj = new Integer(value)…

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

Question

Given: 11. public void genNumbers() { 12. ArrayList numbers = new ArrayList(); 13. for (int i = 0; i < 10; i++) { 14. int value = i * ((int) Math.random()); 15. Integer intObj = new Integer(value); 16. numbers.add(intObj); 17. } 18. System.out.println(numbers); 19. } Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?

Options

  • ALine 16
  • BLine 17
  • CLine 18
  • DLine 19
  • EThe object is NOT a candidate for garbage collection.

How the community answered

(46 responses)
  • A
    9% (4)
  • C
    4% (2)
  • D
    85% (39)
  • E
    2% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice