posted 13 years ago
And given these two fragments:
I. synchronized void move(long id) {
II. void move(long id) {
When either fragment I or fragment II is inserted at line 7, which are true? (Choose all that apply.)
Compilation fails
B. With fragment I, an exception is thrown
C. With fragment I, the output could be 4 2 4 2
D. With fragment I, the output could be 4 4 2 3
E. With fragment II, the output could be 2 4 2 4
Answer:
3 C and E are correct.
I thought the answer is E.But both C and E.How cum it possible..we are using syncronization in Fagment 1 which locks the object.
then how can it acquire the lock of another object??
i searched the posts but couldn't get it.
please explain in detail thanks in advance