Skip to content
Sharp

API Evolution · interview question

What will be the output of the following code? LocalDate date = LocalDate.of(2023, 2, 28); LocalDate newDate = date.plusDays(1); System.out.println(newDate);?

Multiple choiceMediumchapter-12-curatedpremiumapi-evolutionmodern-date-and-time
java
LocalDate date = LocalDate.of(2023, 2, 28);
LocalDate newDate = date.plusDays(1);
System.out.println(newDate);
Choose one answer
Answer and explanation

Correct answer

A. 2023-03-01

Why

Adding one day to February 28th, 2023 gives March 1st, 2023. The LocalDate.plusDays method correctly handles month transitions, including leap years.

Test yourself on API Evolution

A free test with instant, explained results. No account needed.

Start free test
All API Evolution questions →