API Evolution interview questions
Migration Strategy, Modern Date and Time
27 questions with answers and explanations · 27 flashcards
Questions
- How does the java.time package improve architectural design over java.util.Date?Multiple choiceMedium
- What does subtracting one month from March 31 using java.time.LocalDate evaluate to?Multiple choiceMedium
- How does java.time.Instant ensure thread safety?Multiple choiceMedium
- 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
- How would you calculate the number of days between two java.time.LocalDate objects?Multiple choiceHard
- When comparing two Instant objects, which method would you use?Multiple choiceMedium
- What will be the result of comparing two ZonedDateTime objects from different time zones but representing the same instant?Multiple choiceHard
- Which class would you use to represent a date without a time-zone in the java.time package?Multiple choiceEasy
- Which legacy Java seam is usually the safest first modernization target?Multiple choiceMedium
- In a multithreaded e-commerce application, which class would be preferable for handling timestamps and why?Multiple choiceHard
- Which java.time class would you use to represent a date and time without timezone information?Multiple choiceEasy
- How can you convert a legacy java.util.Date object to a java.time.Instant in modern Java?Multiple choiceHard
- Why is using java.time.LocalDate preferred over java.util.Date for representing a date without time?Multiple choiceEasy
- How would you explain a potential pitfall of using LocalDateTime for a global e-commerce application in an interview?Multiple choiceHard
- How would you convert a java.time.LocalDateTime to a java.time.Instant?Multiple choiceHard
- Which java.time class would you use to represent a point in time in UTC?Multiple choiceEasy
- Why is a giant syntax-only migration risky?Multiple choiceEasy
- Which modernization strategy is usually safest for a large legacy Java codebase?Multiple choiceHard
- Which java.time class is specifically designed to handle a date with time-zone information?Multiple choiceEasy
- Given a LocalDate of a product launch date, how would you express the same date in the 'America/New_York' timezone?Multiple choiceMedium
- Which java.time class would you use to store a future delivery date and time that accounts for different time zones?Multiple choiceMedium
- How would you explain the key difference between Duration and Period in the java.time package in an interview?Multiple choiceMedium
- How would you add 5 days to a java.time.LocalDate object?Multiple choiceMedium
- In Java, how would you represent a recurring quarterly subscription as a duration?Multiple choiceMedium
- Which class should you use to represent an immutable point in time on the timeline in UTC?Multiple choiceEasy
- Why do teams use java.time over java.util.Date in production code?Multiple choiceEasy
- How would you create a ZonedDateTime for the current moment in the 'America/New_York' timezone?Multiple choiceHard