Skip to content
Sharp

API Evolution · interview question

When comparing two Instant objects, which method would you use?

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

Correct answer

A. CompareTo()

Why

The compareTo() method is used to compare two Instant objects. It returns a positive number if the first instant is later, a negative number if earlier, and zero if they are equal.

Test yourself on API Evolution

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

Start free test
All API Evolution questions →