Assume the existence of a BankAccount class with a constructor that accepts two parameters: a string for the account holder’s name, followed by an integer for the account number. Assume a subclass SavingsAccount has been defined with a double nstance variable named interestRate. Write a constructor for SavingsAccount that accepts three parameters (in the following order): a string and an integer that are passed to the constructor of BankAccount, and a double that is used to initialize the instance variable.

Assume the existence of a BankAccount class with a constructor that accepts two parameters: a string for the account holder’s name, followed by an integer for the account number. Assume a subclass SavingsAccount has been defined with a double  nstance variable named interestRate. Write a constructor for SavingsAccount that accepts three parameters (in the following order): a string and an integer that are passed to the constructor  of BankAccount, and a double that is used to initialize the instance variable.

LANGUAGE: JAVA

CHALLENGE:

Assume the existence of a BankAccount class with a constructor that accepts two parameters: a string for the account holder’s name, followed by an integer for the account number. Assume a subclass SavingsAccount has been defined with a double nstance variable named interestRate. Write a constructor for SavingsAccount that accepts three parameters (in the following order): a string and an integer that are passed to the constructor of BankAccount, and a double that is used to initialize the instance variable.

SOLUTION:

public SavingsAccount(String name, int socSecNum, double interestRate){ 
   super(name, socSecNum);
   this.interestRate = interestRate;
}

Add comment