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

Discussion

Which of these statements about the value setPriority() actually stores is correct?

  • A.setPriority() throws IllegalArgumentException if the value exceeds the thread group's maximum.
  • B.setPriority() always stores exactly the value supplied, between 1 and 10.
  • C.setPriority() may only be called before the thread is started.
  • D.setPriority() may store a lower value than requested.

Answer: D

The javadoc says the priority is set to the smaller of the requested value and the maximum permitted for the thread's thread group, so a request above that cap is quietly reduced rather than rejected. Values outside 1 to 10 are what cause IllegalArgumentException, and priority may be changed at any time.

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

Post your comment

Please log in or register to post a comment.