Java OCA OCP Practice Question 2793

Question

What is the output of the following code?

LocalDate date = LocalDate.of(2020, Month.APRIL, 40); 
System.out.println(date.getYear() + " " + date.getMonth() 
   + " "+ date.getDayOfMonth()); 
  • A. 2020 APRIL 4
  • B. 2020 APRIL 30
  • C. 2020 MAY 10
  • D. Another date
  • E. The code does not compile.
  • F. A runtime exception is thrown.


F.

Note

Java throws an exception if invalid date values are passed.

There is no 40th day in April-or any other month for that matter.




PreviousNext

Related