Skip to content
Sharp

Core Java · interview question

How can BigDecimal pitfalls be avoided when performing financial calculations?

Multiple choiceMediumchapter-7-curatedpremiumcore-javacode-reading-with-modern-java
Choose one answer
Answer and explanation

Correct answer

A. Always use the BigDecimal constructor with a String.

Why

Using the BigDecimal constructor with a String ensures precision is maintained, avoiding floating-point errors that can occur with doubles.

Test yourself on Core Java

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

Start free test
All Core Java questions →