Java Reference
In-Depth Information
6. What state can a WAITING thread transition into? (Select one.)
A. NEW
B. RUNNABLE
C. BLOCKED
D. TIMED_WAITING
E. TERMINATED
7. If the state of a thread is BLOCKED, what must its previous state have been? (Select all that
apply.)
A. NEW
B. RUNNABLE
C. WAITING
D. TIMED_WAITING
E. TERMINATED
8. Fill in the blanks: A thread that invokes wait is a
and a thread
that invokes notify or notifyAll is a
.
9. Given the following BankAccount class definition, which of the following statements are
true? (Select two.)
1. public class BankAccount {
2. private double balance;
3.
4. public synchronized void deposit(double amount) {
5. balance += amount;
6. }
7.
8. public void withdraw(double amount) {
9. synchronized(this) {
10. balance -= amount;
11. }
12. }
13.
14. public double getBalance() {
15. return balance;
16. }
17. }
A. The lock being acquired on line 4 is for the this reference.
B. A thread must have the appropriate monitor lock before invoking the deposit method.
C. Line 4 generates a compiler error.
Search WWH ::




Custom Search