[Java] 携程Java工程师——一道面向对象面试选择题 →→→→→进入此内容的聊天室

来自 , 2020-11-14, 写在 Java, 查看 149 次.
URL http://www.code666.cn/view/84438b7a
  1. public class Base
  2. {
  3.     private String baseName = "base";
  4.     public Base()
  5.     {
  6.         callName();
  7.     }
  8.  
  9.     public void callName()
  10.     {
  11.         System. out. println(baseName);
  12.     }
  13.  
  14.     static class Sub extends Base
  15.     {
  16.         private String baseName = "sub";
  17.         public void callName()
  18.         {
  19.             System. out. println (baseName) ;
  20.         }
  21.     }
  22.     public static void main(String[] args)
  23.     {
  24.         Base b = new Sub();
  25.     }
  26. }
  27. //输出结果

回复 "携程Java工程师——一道面向对象面试选择题"

这儿你可以回复上面这条便签

captcha