What is the result of the following?
11: LocalDate waffleDay = LocalDate.of(2017, Month.MARCH, 25);
12: Period period = Period.ofYears(1).ofMonths(6).ofDays(3);
13: LocalDate later = waffleDay.plus(period);
14: later.plusDays(1);
15: LocalDate thisOne = LocalDate.of(2018, Month.SEPTEMBER, 28);
16: LocalDate thatOne = LocalDate.of(2018, Month.SEPTEMBER, 29);
17: System.out.println(later.isBefore(thisOne) + " "
18: + later.isBefore(thatOne));
C.
Line 12 creates a Period representing three days.
Period objects do not chain, so only the last method call, which is to ofDays(3)
, is used in determining the value.
Adding three days sets later to March 28, 2017.
Line 14 has no effect as the return value is ignored.
March 28, 2017, is before both thisOne
and thatOne
, so Option C is correct.