Page 842 - AP Computer Science A, 7th edition
P. 842

7. (E) The addInterest method is defined only in the SavingsAccount class. It therefore cannot be invoked by a BankAccount object. The error can be fixed by casting s to the correct type:
((SavingsAccount) s).addInterest();
The other method calls do not cause a problem because withdraw and deposit are both methods of the BankAccount class.
































































































   840   841   842   843   844