nerdexam
GIAC

GSSP-JAVA · Question #75

You have the following code fragment of a Java program named test. 12. public void getData(){ 13. ArrayList numbers=new ArrayList(); 14. for(int i=0; i<10;1++){ 15. int value=i*((int i)…

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

Question

You have the following code fragment of a Java program named test. 12. public void getData(){ 13. ArrayList numbers=new ArrayList(); 14. for(int i=0; i<10;1++){ 15. int value=i*((int i) Math.random()); 16. Integer obj=new Integer(value); 17. numbers.add(obj); 18. } 19. System.out.println(numbers); 20. } On which of the following lines of code will the object referenced by obj be eligible for garbage collection?

Options

  • ALine 18
  • BLine 19
  • CLine 17
  • DLine 20

How the community answered

(58 responses)
  • A
    7% (4)
  • B
    16% (9)
  • C
    3% (2)
  • D
    74% (43)

Community Discussion

No community discussion yet for this question.

Full GSSP-JAVA Practice