OCA Java SE 8 Core Java APIs - OCA Mock Question Core Java APIs 2-9








Question

What is the output of the following code?

     LocalDate date = LocalDate.parse("2016-04-30", 
        DateTimeFormatter.ISO_LOCAL_DATE); 
     date.plusDays(2); 
     date.plusHours(3); 
     System.out.println(date.getYear() + " " 
        + date.getMonth() + " " + date.getDayOfMonth()); 
  1. 2016 APRIL 2
  2. 2016 APRIL 30
  3. 2016 MAY 2
  4. The code does not compile.
  5. A runtime exception is thrown.




Answer



D.

Note

A LocalDate does not have a time element. It has no method to add hours.