← Quiz: Date and Time in Java: all 10 questions
Quiz: Date and Time in Java · Question 1 of 10
What does this print? (code)
What does this print?
import java.time.*;
public class Main {
public static void main(String[] args) {
LocalDate d = LocalDate.of(2026, 5, 10);
d.plusDays(5);
System.out.println(d);
}
}
- A.2026-05-15
- B.2026-05-10
- C.2026-06-10
- D.Compile error
Answer & explanation
Correct answer: 2026-05-10
LocalDate is immutable. plusDays returns a new date, which is thrown away here, so d is unchanged.
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 →