java中垃圾收集_Java中垃圾收集的合格变量

我正准备

OCPJP,我被困在以下模拟考试问题:

鉴于:

3. interface Animal { void makeNoise(); }

4. class Horse implements Animal {

5. Long weight = 1200L;

6. public void makeNoise() { System.out.println("whinny"); }

7. }

8. public class Icelandic extends Horse {

9. public void makeNoise() { System.out.println("vinny"); }

10. public static void main(String[] args) {

11. Icelandic i1 = new Icelandic();

12. Icelandic i2 = new Icelandic();

12. Icelandic i3 = new Icelandic();

13. i3 = i1; i1 = i2; i2 = null; i3 = i1;

14. }

15. }

到达第14行时,有多少对象符合垃圾收集器的条件?

A. 0

B. 1

C. 2

D. 3

E. 4

F. 6

他们的正确答案是E,即四个物体,但我不确定为什么.从我的角度来看,i2及其重量将有资格进行垃圾收集.也许我错过了什么,请指教.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值