Skip to content
Sharp

Modern Java · interview question

How can static factory methods improve domain modeling in Java?

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

Correct answer

C. By enhancing encapsulation of creation logic.

Why

Static factory methods encapsulate the creation logic, allowing for more control over how objects are instantiated, which can improve the clarity and maintainability of the domain model.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →