please explain the answer of this question
class I {
private
String name;
public String toString() {return name;}
public I(String s) {name = s;}
}
class J {
private static void m1(I[] a1) {a1 = null;}
public static void main (String[] args) {
I[] a1 = new I[3]; // 1
a1[0] = new I("A"); // 2
a1[1] = new I("B"); // 3
a1[2] = new I("C"); // 4
m1(a1);
for (int i = 0; i < a1.length; i++) {
System.out.print(a1[i]);
}}}
After method m1 returns, the object created on which line is eligible for garbage collection?
a. 1
b. 2
c. 3
d. 4
e. Compile-time error
f. Run-time error
g. None of the above
answer is g:none of the above
when array a1 is passed to method m1 refrence to array object a1 is passed.
Then when reference of a1 is made null why doesn't it reflect in the calling method.
why is it not ready for garbage collection.
please explain..
Thank you,
sunitha