Multiple Choice
Assume two threads share a BankAccount object with balance of zero (0) , and that the BankAccount class provides synchronized deposit and withdraw methods. Thread one deposits $10 ten times and, concurrently, thread two withdraws $10 ten times. Which statement regarding the balance after all thread calls is definitely true? public synchronized void deposit(int dollars)
{
Int newBalance = balance + dollars;
System.out.println("depositing") ;
Balance = newBalance;
}
Public synchronized void withdraw(int dollars)
{
Int newBalance = balance - dollars;
System.out.println("withdrawing") ;
Balance = newBalance;
}
A) The balance could be zero or positive.
B) The balance is zero.
C) The balance could be zero or negative.
D) The balance is positive.
Correct Answer:

Verified
Correct Answer:
Verified
Q7: Which of the following does not create
Q8: Consider the following change to the deposit
Q14: Which of the following class declarations could
Q15: Which of the following definitely indicates that
Q26: The sleep method is terminated with a(n)
Q30: What happens when a thread calls the
Q33: When a sleeping thread is interrupted, a(n)
Q55: To start a thread, you should first
Q66: The _ occurs when a thread that
Q69: The _ method is called by a