AP Computer Science Unit 9 Test Review Practice Questions

Access More Questions
Questions 1–10 refer to the BankAccount , SavingsAccount , and CheckingAccount classes defined below: public class BankAccount { private double balance; public BankAccount() { balance = 0; } public BankAccount(double acctBalance) { balance = acctBalance; } public void deposit(double amount) { balance += amount; } public void withdraw(double amount) { balance -= amount; } public double getBalance() { return balance; } } public class SavingsAccount extends BankAccount { private double interestRate; public SavingsAccount() { /* implementation not shown */ } public SavingsAccount(double acctBalance, double rate) { /* implementation not shown */ } public void addInterest() //Add interest to balance { /* implementation not shown */ } } public class CheckingAccount extends BankAccount { private static final double FEE = 2.0; private static final double MIN_BALANCE = 50.0; public CheckingAccount(double acctBalance) { /* implementation not shown */ } /** FEE of $2 deducted if withdrawal leaves balance less * than MIN_BALANCE. Allows for negative balance. */ public void withdraw(double amount) { /* implementation not shown */ } } Which is correct implementation code for the withdraw method in the CheckingAccount class?
Correct Answer:
super.withdraw(amount); if (getBalance() < MIN_BALANCE) super.withdraw(FEE);
Explanation:
Correct answer: super.withdraw(amount); if (getBalance() < MIN_BALANCE) super.withdraw(FEE);

Access more questions from this quiz

Continue to AP Computer Science Unit 9 Test Review Practice Questions for more practice questions and the full quiz experience.

Access More Questions