How many 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(); }
I. LocalDate now = LocalDate.now(); II. LocalDate now = new LocalDate(); III. LocalDateTime now = LocalDateTime.now(); IV. LocalDateTime now = new LocalDateTime(); V. ZonedDate now = ZonedDate.now(); VI. ZonedDate now = new ZonedDate();
C.
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 II, IV, and VI incorrect.
Further, there is not a ZonedDate
class.
There is a ZonedDateTime class.
This additionally makes V incorrect.
Both I and III compile, so Option C is correct.