Java OCA OCP Practice Question 1849

Question

Which correctly fills in the blank to print 2020-01-15?

LocalDate hatDay = LocalDate.of(2020, Month.JANUARY, 15); 
DateFormatter f = DateFormatter.ISO_DATE; 
System.out.println(___); 
A.   f.format(hatDate)
B.  hatDay.format(f)
C.  Both of the above
D.  Neither of the above


D.

Note

There is a DateTimeFormatter class, but not a DateFormatter class.

The DateTimeFormatter class is used for formatting dates, times, or both.

Since the provided code does not compile, nothing can fill in the blank to make the code print 2020-01-15, and Option D is the answer.




PreviousNext

Related