Java OCA OCP Practice Question 1837

Question

How many of the classes LocalDate, Period, and ZonedDate have a method to get the year?

  • A. None
  • B. One
  • C. Two
  • D. Three


C.

Note

The LocalDate class represents a date using year, month, and day fields.

There is a getYear() method to get the year.

The Period class holds units of years, months, and days.

It has a getYears() method.

There is not a date/time class called ZonedDate.

There is a class called ZonedDateTime, which does have a getYear() method.

Since only LocalDate and Period have a method to get the year, Option C is correct.




PreviousNext

Related