Skip to content
Sharp

Modern Java · interview question

When should you prefer using BigDecimal over double in Java?

Multiple choiceMediumchapter-7-curatedpremiummodern-javamodern-java-design-choices
Choose one answer
Answer and explanation

Correct answer

C. When precision is critical, such as in financial calculations

Why

BigDecimal is preferred over double when precision is critical because doubles can introduce rounding errors. This is especially important in financial calculations where precise decimal representation is necessary.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →