QuestionQ61

Java SE APIs

Given the following code:

Question Image

What is the result?

  • A 1212
  • B 1111
  • C 1101
  • D 1201
  • E A runtime exception is thrown.
  • F Compilation fails.
Explanation

minusDays(-1) advances the date by one day, and the conditional expression evaluates to false, leaving the date-time at 2021-01-02T11:11. DateTimeFormatter pattern letter H denotes hour-of-day, while uppercase M denotes month-of-year; therefore HHMM formats this value as 1101.

Learn more

Community Discussion

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