Java OCA OCP Practice Question 3103

Question

Choose the correct option based on this code segment:

LocalDate feb28th = LocalDate.of(2015, Month.FEBRUARY, 28);
System.out.println(feb28th.plusDays(1));
  • a) this program prints: 2015-02-29
  • b) this program prints: 2015-03-01
  • c) this program throws a java.time.DateTimeException
  • d) this program throws a java.time.temporal.UnsupportedTemporalTypeException


b)

Note

Since 2015 is not a leap year, there are only 28 days in February.

hence adding a day from 28th February 2015 results in 1st March 2015 and that is printed.




PreviousNext

Related