QuestionQ120

Working with Selected Classes from the Java API

Given the following code fragment:

Question Image

What is the outcome?

  • A 2012-02-10
  • B 2012-02-11
  • C Compilation fails
  • D A DateTimeException is thrown at runtime.
Explanation

LocalDate.of(int year, int month, int dayOfMonth) requires a valid day for the specified month and year. January 32 is invalid, so the construction throws a DateTimeException at runtime before plusDays(10) executes.

Learn more

Community Discussion

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