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

Discussion

Which of these calls to setPriority throws IllegalArgumentException?

  • A.t.setPriority(Thread.NORM_PRIORITY);
  • B.t.setPriority(11);
  • C.t.setPriority(10);
  • D.t.setPriority(1);

Answer: B

The permitted range runs from MIN_PRIORITY, which is 1, to MAX_PRIORITY, which is 10, so 11 is rejected with IllegalArgumentException. The other three are all inside the range. The exception is unchecked, so nothing forces a caller to handle it.

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

Post your comment

Please log in or register to post a comment.