Skip to content
Sharp

Core Java · interview question

When converting a double representing a price to BigDecimal, which constructor should you avoid?

Multiple choiceMediumchapter-1-curatedpremiumcore-javanumeric-types-and-money-basics
Choose one answer
Answer and explanation

Correct answer

B. New BigDecimal(doubleValue)

Why

Using new BigDecimal(double) can cause precision issues because it takes the binary floating-point value directly. It's recommended to use BigDecimal.valueOf(double) or convert the double to String first.

Test yourself on Core Java

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

Start free test
All Core Java questions →