我正准备
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及其重量将有资格进行垃圾收集.也许我错过了什么,请指教.