9. BankAccount and SavingsAccount Classes Design an abstract class named BankAccount to hold the following data for a bank account: • Balance • Number of deposits this month
Added by Jose S.
Close
Step 1
Step 1: Create an abstract class named BankAccount with the following data members: - balance (double) - numberOfDeposits (int) Show more…
Show all steps
Your feedback will help us improve your experience
Madhur L and 91 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Q2: Create an abstract class 'Bank' with an abstract method 'getBalance'. $100, $150, and $200 are deposited in banks A, B, and C respectively. 'BankA', 'BankB', and 'BankC' are subclasses of class 'Bank', each having a method named 'getBalance'. Call this method by creating an object of each of the three classes.
Madhur L.
Use the following for Questions A program to test the BankAccount, SavingsAccount, and CheckingAccount classes has these declarations: BankAccount $\mathrm{b}=$ new BankAccount (1400) ; BankAccount $s=$ new SavingsAccount (1000,0.04) ; BankAccount $c=$ new CheckingAccount (500) ; Which method call will cause an error? (A) b.deposit(200) ; (B) s.withdraw(500); (C) c.withdraw(500); (D) s. deposit(10000) ; (E) s.addInterest() ;
Use the following for Questions A program to test the BankAccount, SavingsAccount, and CheckingAccount classes has these declarations: BankAccount $\mathrm{b}=$ new BankAccount (1400) ; BankAccount $s=$ new SavingsAccount (1000,0.04) ; BankAccount $c=$ new CheckingAccount (500) ; In order to test polymorphism, which method must be used in the program? (A) Either a SavingsAccount constructor or a CheckingAccount constructor (B) addInterest (C) deposit (D) withdraw (E) getBalance
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD