JAVA super关键字 初学者笔记

public class Manager extends Employee
{
   private double bonus;

   public Manager(String name, double salary, int year, int month, int day)
   {
      super(name, salary, year, month, day);//调用超类中含name, salary, year, month, day参数的构造器
      bonus = 0;
   }

   public double getSalary()
   {
      double baseSalary = super.getSalary();//调用超类中的getSalary()方法
      return baseSalary + bonus;
   }

   public void setBonus(double b)
   {
      bonus = b;
   }
}

 

posted @ 2020-03-28 20:18  main(void)  阅读(209)  评论(0编辑  收藏  举报
.c_ad_block { display: none !important; } #ad_t2{ display: none !important; }