Skip to content
Sharp

API Evolution · interview question

In Java, how would you represent a recurring quarterly subscription as a duration?

Multiple choiceMediumchapter-12-curatedpremiumapi-evolutionmodern-date-and-time
Choose one answer
Answer and explanation

Correct answer

B. Use Period.ofMonths(3)

Why

Period represents a quantity of time in terms of years, months, and days. For a quarterly duration, Period.ofMonths(3) is appropriate as it captures the concept of 3 months.

Test yourself on API Evolution

A free test with instant, explained results. No account needed.

Start free test
All API Evolution questions →