← Quiz: Date and Time in Java: all 10 questions
Quiz: Date and Time in Java · Question 3 of 10
What does this print? (code)
What does this print?
import java.time.*;
public class Main {
public static void main(String[] args) {
System.out.println(LocalDate.of(2026, 3, 31).plusMonths(1));
}
}
- A.2026-05-01
- B.2026-04-31
- C.It throws DateTimeException
- D.2026-04-30
Answer & explanation
Correct answer: 2026-04-30
April has 30 days, so plusMonths moves to the last valid day of April.
Can you get the rest right without peeking?
Take the timed Quiz: Date and Time in Java quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →