程序为:public class Account{
  protected double balance;
    public Account(double init_balance){
          balance=init_balance;
    }
    public double getBalance(){
           return balance;
    }
    public void deposit(double amt){
           if(amt>0){
                 balance = balance + amt;
                 System.out.println("deposit success");
             
            }
          
           else System.out.println("deposit false");
    }
    public void withdraw(double amt) {
            
           if((balance-amt)>0){
                 balance = balance - amt;
                 System.out.println("Withdraw success");
        
            }
          
           else System.out.println("Withdraw false");
   }
} class SavingsAccount extends Account{
     private double interest_Rate;
     public double SavingAccount(double balance,double interest_rate){
        
        return super.getBalance()*interest_rate;
        
     }
}提示的错误为:Account(double)in Account cannot be applied to()class SavingsAccount extends Account{

解决方案 »

  1.   

    在SavingsAccount类中增加一个构造器:
    public SavingsAccount(double init_balance){
      super(init_balance);
    }
    因为父类没有默认构造器,所以你必须在你的构造器中显式的调用父类构造器
      

  2.   

    由于你的父类中overload了构造函数--》Account(double),所以在子类中必须显示的调用这个父类的构造函数 而不能调用默认的构造函数
      

  3.   

    给父类Account写个默认的无参构造函数:public Account(){
              balance=0;
        }