Java OCA OCP Practice Question 2247

Question

Which one of the following classes is best suited for storing timestamp values of application events in a file?.

  • A. java.time.ZoneId class
  • B. java.time.ZoneOffset class
  • C. java.time.Instant class
  • D. java.time.Duration class
  • e. java.time.Period class


C.

Note

the Instant class stores the number of seconds elapsed since the start of the Unix epoch (1970-01-01t00:00:00Z).

the Instant class is suitable for storing a log of application events in a file as timestamp values.

the ZoneId and ZoneOffset classes are related to time zones and hence are unrelated to storing timestamp values.

the Duration class is for time-based values in terms of quantity of time (such as seconds, minutes, and hours).

the Period class is for date-based values such as years, months, and days.




PreviousNext

Related