题库 软件开发 题目列表 以下代码运行的结果是什么 public class TestGC {...
单选题
以下代码运行的结果是什么
public class TestGC {
    private static TestGC TEST_GC = null;
    private void isAlive() {
        System.out.print("Yes,I'm Alive!" + "、");
    }
    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.print("finalize mehtod executed!" + "、");
        TestGC.TEST_GC = this;
    }
    public static void main(String[] args) throws Throwable {
        TEST_GC = new TestGC();
        TEST_GC = null;
        System.gc();
        Thread.sleep(500);
        if (TEST_GC != null) {
            TEST_GC.isAlive();
        } else {
            System.out.print("NO,I'm dead!" + "、");
        }
        TEST_GC = null;
        System.gc();
        Thread.sleep(500);
        if (TEST_GC != null) {
            TEST_GC.isAlive();
        } else {
            System.out.print("NO,I'm dead!");
        }
    }
}

A.

finalize mehtod executed!、Yes,I'm Alive!、NO,I'm dead!

B.

NO,I'm dead!、NO,I'm dead!

C.

finalize mehtod executed!、Yes,I'm Alive!、finalize mehtod executed!、Yes,I'm Alive!

D.

finalize mehtod executed!、Yes,I'm Alive!、finalize mehtod executed!、NO,I'm dead!

题目信息
校招真题
-
正确率
0
评论
19
点击