package testApp;
class TestApp {
TestB b;
TestApp() {
b = new TestB(this);
System.out.println("Object A Init ed.");
}
protected void finalize(){
System.out.println("DELETING Object A...");
}
}
class TestB {
TestApp a;
TestB(TestApp a) {
this.a = a;
System.out.println("Object B Init ed.");
}
protected void finalize(){
System.out.println("DELETING Object B...");
}
}
class TestAll {
public static void main (String args[]) {
new TestAll().makeThings();
System.out.println("Calling System.gc()...");
System.gc();
for(;;
}
void makeThings() {
TestApp test = new TestApp();
}
}
运行结果是:
Object B Init ed.
Object A Init ed.
Calling System.gc()...
DELETING Object A...
DELETING Object B...
结果表明答案应该选CD