previous |
start |
next
Converting from Subclasses to Superclasses
- Ok to convert subclass reference to superclass reference
- SavingsAccount collegeFund = new SavingsAccount(10);
BankAccount anAccount = collegeFund;
Object anObject = collegeFund;
- Superclass references don't know the full story:
anAccount.addInterest(); // ERROR
- Why would anyone want to know less about an object?
previous |
start |
next