0%
0 / 9 answered
Assignment Statements and Input Practice Test
•9 QuestionsQuestion
1 / 9
Q1
What is the result of the following method call given the input deposit 50.0?
public class BankAccount {
private double balance;
public BankAccount(double startBalance) {
balance = startBalance;
}
public void deposit(double amount) {
balance = balance + amount;
}
public double getBalance() {
return balance;
}
}
BankAccount account = new BankAccount(100.0);
account.deposit(50.0);
double newBalance = account.getBalance();
System.out.println(newBalance);
What is the result of the following method call given the input deposit 50.0?
public class BankAccount {private double balance; public BankAccount(double startBalance) { balance = startBalance; } public void deposit(double amount) { balance = balance + amount; } public double getBalance() { return balance; }}
BankAccount account = new BankAccount(100.0);
account.deposit(50.0);
double newBalance = account.getBalance();
System.out.println(newBalance);