Skip to content
Sharp

Core Java · interview question

Why is it not recommended to use float for calculating the subtotal of an online shopping cart?

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

Correct answer

D. Float can introduce rounding errors

Why

Float can introduce rounding errors in financial calculations due to its limited precision, which can lead to incorrect totals in monetary computations.

Test yourself on Core Java

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

Start free test
All Core Java questions →