nerdexam
GIAC

GSSP-JAVA · Question #144

Mark works as a Programmer for InfoTech Inc. He develops the following code snippet. 1. public class Garbage 2. { 3. public static void main(String args[]) 4. { 5. String line; 6. String first="it…

The correct answer is D. After line 11. See the full explanation below for the reasoning.

Question

Mark works as a Programmer for InfoTech Inc. He develops the following code snippet. 1. public class Garbage 2. { 3. public static void main(String args[]) 4. { 5. String line; 6. String first="it is a program"; 7. String last="last argument"; 8. String arg1=new String((args.length>0) ? "'" + args[0] + "'" . "no arguments"); 9. line=arg1; 10. arg1=null; 11. line=first + line + last; 12. first=null; 13. System.out.println("line"); 14. line=null; 15. last=null; 16. args=null; 17. } 18. } Which of the following statements about the code snippet is true when an object is initially referenced with arg1, and it is eligible for garbage collection?

Options

  • AAfter line 10.
  • BAfter line 15.
  • CAfter line 12.
  • DAfter line 11.

How the community answered

(58 responses)
  • A
    2% (1)
  • B
    9% (5)
  • C
    5% (3)
  • D
    84% (49)

Community Discussion

No community discussion yet for this question.

Full GSSP-JAVA Practice