🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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);
    }
}
  1. A.2026-05-15
  2. B.2026-05-10
  3. C.2026-06-10
  4. 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 →