Skip to content
Sharp

API Evolution · interview question

How would you explain the key difference between Duration and Period in the java.time package in an interview?

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

Correct answer

A. Duration is for time-based, Period is for date-based intervals

Why

Duration is used for time-based intervals such as seconds and nanoseconds, while Period is used for date-based intervals like days, months, and years.

Test yourself on API Evolution

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

Start free test
All API Evolution questions →