Java OCA OCP Practice Question 2791

Question

What is the output of the following code?

LocalDate date = LocalDate.parse("2020-04-30", DateTimeFormatter.ISO_LOCAL_DATE); 
date.plusDays(2); 
date.plusHours(3); 
System.out.println(date.getYear() + " " 
  + date.getMonth() + " "+ date.getDayOfMonth()); 
  • A. 2020 APRIL 2
  • B. 2020 APRIL 30
  • C. 2020 MAY 2
  • D. The code does not compile.
  • E. A runtime exception is thrown.


D.

Note

A LocalDate does not have a time element.

Therefore, it has no method to add hours, and the code does not compile.




PreviousNext

Related