本帖最后由 kongling 于 2013-12-5 17:53 编辑
下面的程序输出什么?为什么?
- public class Test
- {
- public static void main(String[] args)
- {
- Father father=new Father();
- Child child=new Child();
-
- System.out.println(father.a);
- System.out.println(child.a);
- System.out.println(((Father)child).a);
- }
- }
- class Father
- {
- public static String a="father";
- }
- class Child extends Father
- {
- public static String a="child";
- }
复制代码 |