What is the output of the following code?
import java.time.LocalDate; import java.time.Month; public class Main { public static void main(String[] args) { LocalDate date = LocalDate.of(2018, Month.APRIL, 30); date.plusDays(2); /* w w w . j av a 2s . c o m*/ date.plusYears(3); System.out.println(date.getYear() + " " + date.getMonth() + " " + date.getDayOfMonth()); } }
B.
The date starts out as April 30, 2018.
Since dates are immutable and the plus methods have their return values ignored, the result is unchanged.
Therefore, option B is correct.