Question: Given the following code: public class Account private double balance; // instance variable that stores the balance / constructor public Account ( double initialBalance )
Given the following code: public class Account private double balance; // instance variable that stores the balance / constructor public Account ( double initialBalance ) 17 validate that initialbalance is greater than 0.2; Hif it is not, balance is initialized to the default value 0.0 If (InitialBalance > 2.0) balance - Initialbalances 11/ end Account constructor 11 credit (add) an amount to the account public void credit double amount > balance-balance + amount; add anount to balance Blend method credit 1 return the account balance public double setBalancet) return balance gives the value of balance to the calling method > I end method getBalance ) end class Account What is output by the following main method? public static void main(String args) > Account account - new Account -20.17) System.out.printf("account balance: 58.27 ", account.getBalance(): 31end non account balance 0.0 account balance: 20 account balance 2017 account balance is -20.17
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
