Question 1
What does this print? ```java import java.time.*; public class Main { public static void main(String[] args) { LocalDate d = LocalDate.of(2026, 6, 15); LocalDate d2 = d.plusMonths(2).minusDays(5); System.out.println(d + " " + d2); } } ```
A. 2026-08-10 2026-08-10
Assumes plusMonths mutated the original date in place; java.time types never mutate, so the original reference is left untouched at its starting value.
B. 2026-06-15 2026-08-20
Reads minusDays(5) as adding five days (Aug 15 + 5); the method subtracts, not adds.
C. 2026-06-15 2026-06-10
Applies only the minusDays(5) and drops the plusMonths(2), ignoring that both calls chain on the same expression.
D. 2026-06-15 2026-08-10Correct answer
The original date is immutable so it still holds 2026-06-15, while the chained plusMonths(2) then minusDays(5) computes Aug 15 and then Aug 10.
Explanation
`java.time` date types are immutable, so a method call never changes the receiver; the original reference still holds its starting value when printed. The second value comes from a chain in which each call operates on the previous call's return value, left to right: advancing two months to reach Aug 15, then subtracting five days from that intermediate result to reach Aug 10. Reading the two outputs separately — the unchanged original versus the freshly computed chain — is the key to tracing this correctly.