public class Bank Account private double balance public Bank Account balance 0;
ID: 3813730 • Letter: P
Question
public class Bank Account private double balance public Bank Account 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 clasa SavingsAccount extends BankAccount private double interestRatei Public SevingaAccount implementation not shown Y public savingsAccounts (double acctBalance, double rate) implementation not shown k/ public void addInterest //Add interest to balance t impleaentation 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) implexentation not shown 1 FEE of $2 deducted if withdrawal leaves balance less than MIN BALANCE. Allows for negative balance. public void withdraw (double arnount) implementation not shownExplanation / Answer
hi please find the below answer and expalnation
for question 3rd correct option is C & D
for question 4th correct option is E
Explanation as per below
In SavingsAccount class have constructor with parameter is
public SavingsAccount(double accBalance, double rate){
}
for this ques correct option will be C & D
explanation for C -> super() will call parent class constructor with no parameter i.e, public BankAccout(){}
and second line interestRate = rate , it will initialize instace variable "interestRate" in class SavingsAccount
explanation for D -> super(acctBalance) will call parent class constructor with parameter i.e, public BankAccout(double accBalance){}
and second line interestRate = rate , it will initialize instace variable "interestRate" in class SavingsAccount.
Option E is not correct because super(accBalance, rate) and in parent class no any constructor taking two parameters
Option A is incorrect because it is accessing priavte member "balance" from parent class which will be not accessible.
Option B is Wrong because getBalance() returning a int value and here trying to assigns a new value which is wring assignment type;
In CheckingAccount class correct implementation of constructor is
E I,II and III all are correct
Explanation -> I uper(acctBalance) will call parent class constructor with parameter i.e, public BankAccout(double accBalance){}
II super() will call parent class constructor with no parameter i.e, public BankAccout(){}
deposit(accBalance) will invoke Parent class method deposit(double accBalance)
III deposit(accBalance) will invoke Parent class method deposit(double accBalance)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.