Skip to content
Sharp

Modern Java · interview question

Consider a class designed to handle monetary values. Why might a developer choose a static factory method over a constructor for creating instances of BigDecimal?

Multiple choiceHardchapter-7-curatedpremiummodern-javastatic-factory-methods
Choose one answer
Answer and explanation

Correct answer

C. To ensure consistent precision and scale.

Why

Static factory methods can enforce consistent precision and scale when creating BigDecimal instances, which is critical for handling monetary values accurately.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →