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

Discussion

Which of these correctly reads a thread's identifier?

  • A.int id = t.getId();
  • B.String id = t.getId();
  • C.long id = t.id();
  • D.long id = t.getId();

Answer: D

Correct answer: long id = t.getId();

The accessor is getId() and it returns a long, since ids are not reused and could exhaust an int in a long-running process. Assigning it to an int would not compile without a cast, and there is no method simply called id().

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

Post your comment

Please log in or register to post a comment.