AP Computer Science A Quiz
15 questions · no time limit
0:00
CLASS CREATION
Question 1 of 15
No time limit
Current
Answered
Flagged
Not seen
Based on the code snippet above, which describes the state of a and b after transferTo executes?
public class BankAccount {
private String accountNumber;
private double balance;
public BankAccount(String accountNumber, double balance) {
this.accountNumber = accountNumber;
this.balance = balance;
}
// Moves money from this account into another account
public BankAccount transferTo(BankAccount other, double amount) {
this.balance -= amount;
other.balance += amount;
return other;
}
public double getBalance() {
return balance;
}
public static void main(String[] args) {
BankAccount a = new BankAccount("A", 50.0);
BankAccount b = new BankAccount("B", 10.0);
a.transferTo(b, 15.0);
System.out.println(a.getBalance() + "," + b.getBalance());
}
} YOUR PROGRESS
15
QUESTIONS
Ready when you are
Answer in any order. Your progress shows here as you go.
QUESTIONS
KEYBOARD
Pick an answer ABCD
Next question ↵→
Previous ←
Flag for review F
Answers save as you go · flagged questions come back at the end