Question: Identify the location in the following program where the object, initially referenced by arg1, is eligible for garbage collection. Select the one correct answer. (a)
Identify the location in the following program where the object, initially referenced by arg1, is eligible for garbage collection.
![public class MyClass { public static void main(String[] args) { String msg;](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1706/9/5/3/64965be0bb149c481706953645550.jpg)
Select the one correct answer.
(a) After the line labeled (1)
(b) After the line labeled (2)
(c) After the line labeled (3)
(d) After the line labeled (4)
(e) After the line labeled (5)
(f) After the line labeled (6)
public class MyClass { public static void main(String[] args) { String msg; String pre = "This program was called with "; String post = "as first argument."; String argl = new String ((args.length > 0) ? "*" +args [0] + " "); } } msg = arg1; argl = null; msg= pre + msg + post; pre= null; System.out.println (msg); msg= null; post = null; args = null; // (1) // (2) // (3) // (4) // (5) // (6) "1"
Step by Step Solution
3.28 Rating (169 Votes )
There are 3 Steps involved in it
b Before 1 the String object initially referenced by arg1 is denoted by both msg and arg1 ... View full answer
Get step-by-step solutions from verified subject matter experts
