Skip to content
Sharp

Core Java · interview question

What happens if you divide one BigDecimal by another without specifying a rounding mode and the result cannot be represented exactly?

Multiple choiceMediumchapter-7-curatedpremiumcore-javabigdecimal-and-money
Choose one answer
Answer and explanation

Correct answer

A. An ArithmeticException is thrown.

Why

If a division operation results in a non-terminating decimal expansion and no rounding mode is specified, BigDecimal will throw an ArithmeticException, forcing you to define a rounding strategy.

Test yourself on Core Java

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

Start free test
All Core Java questions →