Which of the following can fill in the blank to make this code compile?
public boolean isItMyBirthday(LocalDateTime dateTime) { __________________ return now.getMonth() == dateTime.getMonth() && now.getDayOfMonth() == dateTime.getDayOfMonth(); }
A. LocalDate now = LocalDate.now(); B. LocalDate now = new LocalDate(); C. ZonedDate now = ZonedDate.now(); D. ZonedDate now = new ZonedDate();
A.
Java 8 date and time classes are immutable.
They use a static factory method to get the object reference rather than a constructor.
This makes Options B and D incorrect.
Further, there is not a ZonedDate
class.
There is a ZonedDateTime class.
Option C is incorrect, and Option A is the answer.