Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these declarations does the compiler reject?

  • A.abstract synchronized void process();
  • B.abstract void process();
  • C.synchronized void process() { }
  • D.static synchronized void process() { }

Answer: A

synchronized describes how a method body acquires a lock, and an abstract method has no body, so the two cannot be combined. An abstract declaration on its own is fine, as is synchronized on any method that does have a body.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.