Skip to content
Sharp

Core Java · interview question

What does comparing two BigDecimal objects using compareTo() method evaluate to?

Multiple choiceMediumchapter-7-curatedpremiumcore-javabigdecimal-and-money
Choose one answer
Answer and explanation

Correct answer

A. A positive or negative integer or zero.

Why

The compareTo() method in BigDecimal returns a negative integer, zero, or a positive integer if the first BigDecimal is less than, equal to, or greater than the second, respectively. This is similar to other compareTo methods in Java.

Test yourself on Core Java

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

Start free test
All Core Java questions →