* If savings account is a class, give an example of each of the following as it relates to that * * savings account. Explain your reasoning behind your example. * Superclass Subclass Attribute Method Instance (object) Encapsulation
Answer: Superclass – Savings Account can be a super class. It can be used to hold the generic attributes of a savings account like account number, insured by FDIC flag etc. * Subclass – Passbook Savings and Certificate Of Deposit can be specialized subclasses of Savings Account. A subclass inherits the capabilities of superclass and can add specialized behavior as needed. A Passbook Savings class can override the way interest is calculated if needed. A Certificate Of Deposit can add attribute for early termination fee. * Attribute – account Number, interest Rate, electronic Statement, email Address etc. are examples of attributes present in Savings Account class * Method – calculate Interest, send Statement, deposit, withdraw etc. are example of methods present in savings account class. *