Skip to content
Sharp

Core Java · interview question

How do you correctly initialize a BigDecimal to represent the monetary value 50.75?

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

Correct answer

D. New BigDecimal("50.75")

Why

Using a String to initialize a BigDecimal avoids the precision issues that can occur with floating-point literals in Java, preserving the exact value.

Test yourself on Core Java

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

Start free test
All Core Java questions →