QuestionQ26

Java SE APIs

Given this code fragment:

Question Image

What is the outcome?

  • A Can't logout
  • B Logged out at: 2021-01-12T21:58:00z
  • C A compilation error occurs at line n1.
  • D Logged out at: 2021-01-12T21:58:19.880z
Explanation

Truncating an Instant to ChronoUnit.MINUTES rounds it down to the minute by setting seconds and nanoseconds to zero. Both timestamps therefore become 2021-01-12T21:58:00Z; neither is after the other, so the else branch prints Can't logout.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!