Skip to content
Sharp

Modern Java · interview question

Why might OrderId.from(raw) be clearer than an overloaded constructor?

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

Correct answer

D. Because the factory method can name intent and enforce creation rules explicitly

Why

A static factory can explain whether the call parses, validates, trims, or reuses a value. The point is not novelty, but creation code that communicates intent more clearly to the next reader.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →