Which of the following statements are true about synchronization? (Select two choices)
Options :
A. Static methods cannot be synchronized.
B. Synchronized methods methods cannot make calls to non-synchronized methods
C. A synchronized method can be overridden by a non-synchronized and vice-versa
D. When a Thread is executing a synchronized method of a an object, other threads can freely access non-synchronized methods of the same object.
Answer : C & D.
Static methods can be synchronized. Static synchronized methods acquire lock on the object class and not on the instance. so Option A is incorrect.
Synchronized methods can make calls to non-synchronized methods. [ This is slightly out of context but : Only static methods can not make calls to non-static methods ] so option B is incorrect.
No comments:
Post a Comment