public class Base { private String baseName = "base"; public Base() { callName(); } public void callName() { System. out. println(baseName); } static class Sub extends Base { private String baseName = "sub"; public void callName() { System. out. println (baseName) ; } } public static void main(String[] args) { Base b = new Sub(); } }
上面代码输出什么?
答案是
null
分析:
原文:https://www.cnblogs.com/cracker13/p/9398966.html