Skip to content
Sharp

Core Java · interview question

Which approach is the best fit to add two BigDecimal objects, value1 and value2?

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

Correct answer

B. Value1.add(value2)

Why

The add method on a BigDecimal instance is used to add two BigDecimal objects. This ensures precise arithmetic without the pitfalls of using operators like +.

Test yourself on Core Java

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

Start free test
All Core Java questions →