Java OCA OCP Practice Question 727

Question

What is the output of the following?

LocalDate xmas = LocalDate.of(2016,  12,  25); 
xmas.plusDays(-1); 
System.out.println(xmas.getDayOfMonth()); 
  • A. 24
  • B. 25
  • C. 26
  • D. None of the above


B.

Note

Java 8 date and time classes are immutable.

The plusDays() method returns a LocalDate object presenting Christmas Eve (December 24th).

This return value is ignored.

The xmas variable still represents the original value, so Option B is correct.




PreviousNext

Related