Welcome Guest | Sign in | Register
Threads - Discussion Page For Q.2942 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Threads > Questions and Answers

Q: Which statement is true?
A. A static method cannot be synchronized. B. If a class has synchronized code, multiple threads can still access the non synchronized code.
C. Variables can be protected from concurrent access problems by marking them with the synchronized keyword. D. When a thread sleeps, it releases its locks.

Answer and Explanation

Answer:If a class has synchronized code, multiple threads can still access the non synchronized code.

Explanation:
B is correct because multiple threads are allowed to enter nonsynchronized code, even within a class that has some synchronized methods.
A is incorrect because static methods can be synchronized; they synchronize on the lock on the instance of class java.lang.Class that represents the class type.
C is incorrect because only methods—not variables—can be marked synchronized.
D is incorrect because a sleeping thread still maintains its locks.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved 2012-2015 SoftLucent.