菜鸟请教

本帖于 2012-03-18 12:39:25 时间, 由普通用户 未知未觉 编辑

菜鸟请教一个java的基础面试题。

 
------------------------------------------------------
public class D
{
 public int a=10;
 public int test() { return a; }
}
------------------------------------------------------
public class E extends D
{
 public int a=20;
 public int test() { return a; }
}
------------------------------------------------------
Now suppose 
 
D d=new E();
 
So d.a = ? and d.test()=?
 
I understand d.test() is 20, due to inheritance finds the lowest level method and call.
But why d.a is 10? 
请您先登陆,再发跟帖!