0%
0 / 25 answered

Practice Test 7

25 Questions
Question
1 / 25
Q1

public class BankAccount {

private double balance;

private String accountNumber;



public BankAccount(String num, double initialBalance) {

    accountNumber = num;

    balance = initialBalance;

}



public void deposit(double amount) {

    balance += amount;

}



public boolean withdraw(double amount) {

    if (amount <= balance) {

        balance -= amount;

        return true;

    }

    return false;

}



public double getBalance() {

    return balance;

}

}

Consider the following code segment:

BankAccount account = new BankAccount("12345", 100.0);

account.deposit(50.0);

boolean success1 = account.withdraw(75.0);

boolean success2 = account.withdraw(100.0);

double finalBalance = account.getBalance();

What are the values of success1, success2, and finalBalance?

Question Navigator