10.4 Programming Activity 1: Using Inheritance

For this Programming Activity, you will create the SavingsAccount class, which inherits directly from the BankAccount class. The SavingsAccount class is similar to the CheckingAccount class in that both classes inherit from BankAccount. Figure 10.9 shows the resulting hierarchy.

Figure 10.9Bank Account Hierarchy

The SavingsAccount class inherits from the version of the BankAccount class in which the balance is declared to be private. The SavingsAccount subclass adds an annual interestRate instance variable, as well as supporting methods to access, change, and apply the interest rate to the ...

Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.