Skip to content
Sharp

API Evolution interview questions

Migration Strategy, Modern Date and Time

27 questions with answers and explanations · 27 flashcards

Questions

  1. How does the java.time package improve architectural design over java.util.Date?Multiple choiceMedium
  2. What does subtracting one month from March 31 using java.time.LocalDate evaluate to?Multiple choiceMedium
  3. How does java.time.Instant ensure thread safety?Multiple choiceMedium
  4. What will be the output of the following code? LocalDate date = LocalDate.of(2023, 2, 28); LocalDate newDate = date.plusDays(1); System.out.println(newDate);?Multiple choiceMedium
  5. How would you calculate the number of days between two java.time.LocalDate objects?Multiple choiceHard
  6. When comparing two Instant objects, which method would you use?Multiple choiceMedium
  7. What will be the result of comparing two ZonedDateTime objects from different time zones but representing the same instant?Multiple choiceHard
  8. Which class would you use to represent a date without a time-zone in the java.time package?Multiple choiceEasy
  9. Which legacy Java seam is usually the safest first modernization target?Multiple choiceMedium
  10. In a multithreaded e-commerce application, which class would be preferable for handling timestamps and why?Multiple choiceHard
  11. Which java.time class would you use to represent a date and time without timezone information?Multiple choiceEasy
  12. How can you convert a legacy java.util.Date object to a java.time.Instant in modern Java?Multiple choiceHard
  13. Why is using java.time.LocalDate preferred over java.util.Date for representing a date without time?Multiple choiceEasy
  14. How would you explain a potential pitfall of using LocalDateTime for a global e-commerce application in an interview?Multiple choiceHard
  15. How would you convert a java.time.LocalDateTime to a java.time.Instant?Multiple choiceHard
  16. Which java.time class would you use to represent a point in time in UTC?Multiple choiceEasy
  17. Why is a giant syntax-only migration risky?Multiple choiceEasy
  18. Which modernization strategy is usually safest for a large legacy Java codebase?Multiple choiceHard
  19. Which java.time class is specifically designed to handle a date with time-zone information?Multiple choiceEasy
  20. Given a LocalDate of a product launch date, how would you express the same date in the 'America/New_York' timezone?Multiple choiceMedium
  21. Which java.time class would you use to store a future delivery date and time that accounts for different time zones?Multiple choiceMedium
  22. How would you explain the key difference between Duration and Period in the java.time package in an interview?Multiple choiceMedium
  23. How would you add 5 days to a java.time.LocalDate object?Multiple choiceMedium
  24. In Java, how would you represent a recurring quarterly subscription as a duration?Multiple choiceMedium
  25. Which class should you use to represent an immutable point in time on the timeline in UTC?Multiple choiceEasy
  26. Why do teams use java.time over java.util.Date in production code?Multiple choiceEasy
  27. How would you create a ZonedDateTime for the current moment in the 'America/New_York' timezone?Multiple choiceHard