Assume the existence of a BankAccount class. Define a subclass, SavingsAccount that contains the following: a double instance variable, interestRate a constructor that accepts a parameter of type double which is used to initialize the instance variable

Assume the existence of a BankAccount class.  Define a subclass, SavingsAccount that contains the following: a double instance variable, interestRate a constructor that accepts a parameter of type double which is used to initialize the instance variable

LANGUAGE: JAVA

CHALLENGE:

Assume the existence of a BankAccount class.

Define a subclass, SavingsAccount that contains the following:
a double instance variable, interestRate
a constructor that accepts a parameter of type double which is used to initialize the instance variable

SOLUTION:

public class SavingsAccount extends BankAccount{
   private double interestRate;
   public SavingsAccount(double interestRate) {
      this.interestRate = interestRate;
   }
}

Add comment