Java OCA OCP Practice Question 1272

Question

Which of the following may not be synchronized?

  • A. Blocks within methods
  • B. Static methods
  • C. Blocks within static methods
  • D. Classes


D.

Note

You can synchronize a block inside a method by preceding the block with synchronized.

You can declare a static method to be synchronized.

Since there is no object for the static method, the thread that executes the method will synchronize on a lock belonging to the class.

You can synchronize a block inside a static method.




PreviousNext

Related