QuestionQ112

Working with Selected Classes from the Java API

Given this code fragment:

Question Image

What is the result?

  • A An exception is thrown at runtime.
  • B 2014-07-31T01:01:00
  • C 2014-07-31
  • D 2014-09-30T00:00:00
Explanation

LocalDateTime is immutable, and both plusDays and plusMonths return new instances rather than modifying the original value. Because neither return value is assigned, the value remains July 31, 2014 at 01:01. ISO_DATE_TIME formats it as 2014-07-31T01:01:00.

Learn more

Community Discussion

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