Skip to content
Sharp

Core Java · interview question

Why might using double for currency calculations in an e-commerce application lead to inaccuracies?

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

Correct answer

A. It may cause rounding errors.

Why

The double type can lead to rounding errors because it uses floating-point arithmetic, which is not always precise with decimal values. This can cause inaccuracies in financial calculations.

Test yourself on Core Java

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

Start free test
All Core Java questions →