QuizzesDate and Time API — Concept Check
intermediate
java

Date and Time API — Concept Check

Questions on Date and Time API. Java 8's java.time package provides an immutable, thread-safe date and time API that replaces the error-prone legacy Date and Calendar classes.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Date and Time API — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer needs to store a user's birth date in a Java application. Which java.time type should they use?

    • AInstant
    • BLocalDate
    • CLocalDateTime
    • DZonedDateTime
  2. 2.You have a meeting scheduled at 3 PM in New York and need to convert it to London time. Which class should you use?

    • AInstant
    • BLocalDateTime
    • CLocalTime
    • DZonedDateTime
  3. 3.A developer is comparing two LocalDate instances to check if one is before the other. Which method should they use?

    • AisAfter()
    • BisBefore()
    • CcompareTo()
    • Dequals()
  4. 4.Which method would you use to add 5 days to a LocalDate object?

    • AplusDays(5)
    • BappendDays(5)
    • CaddDays(5)
    • DincrementDays(5)
  5. 5.A developer is parsing a date string '2025-06-15' using DateTimeFormatter.ISO_LOCAL_DATE. What will be the result?

    • AA LocalDateTime with default time
    • BA LocalDate representing June 15, 2025
    • CAn Instant representing the start of the day
    • DA ZonedDateTime with system default zone
  6. 6.Why might a developer choose Duration over Period for measuring time intervals?

    • APeriod handles time zones automatically
    • BDuration measures time-based intervals, suitable for hours and minutes
    • CPeriod is more precise for small time intervals
    • DDuration is mutable, allowing easy updates
  7. 7.A developer mistakenly uses LocalDateTime to store a timestamp for a global event. What issue might arise?

    • AInability to perform arithmetic
    • BIncorrect date storage
    • CInability to format the date
    • DLack of timezone information
  8. 8.Which of the following is NOT a method for creating instances in java.time?

    • Afrom()
    • Bparse()
    • Cof()
    • Dnow()