Tôi đã trải qua câu hỏi này trên một trang web chuẩn bị SCJP. Câu trả lời A đúng như thế nào?Bộ sưu tập rác java
Điều gì là đúng về các đối tượng được tham chiếu bởi a, b, aa tại dòng có gắn nhãn "// một số mã đi tại đây"?
class A {
private B b;
public A() {
this.b = new B(this);
}
}
class B {
private A a;
public B(A a) {
this.a = a;
}
}
public class Test {
public static void main(String args[]) {
A aa = new A();
aa = null;
// some code goes here
}
}
A) The objects referenced by a and b are eligible for garbage collection.
B) None of these objects are eligible for garbage collection.
C) Only the object referenced by "a" is eligible for garbage collection.
D) Only the object referenced by "b" is eligible for garbage collection.
E) Only the object referenced by "aa" is eligible for garbage collection.
Trả lời: Một Java