QuestionQ54

Working with Selected Classes from the Java API

Given this code fragment:

Question Image

What is the outcome?

  • A 2012-02-10 00:00
  • B 2012-01-30
  • C 2012-02-10
  • D A DateTimeException is thrown at runtime.
Explanation

LocalDate is immutable, so calling plusDays(10) does not change the existing instance. Because the returned date is ignored, printing date produces 2012-01-30.

Community Discussion

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