Skip to content
Sharp

Modern Java · interview question

How would you explain a potential advantage of using static factory methods over constructors in terms of instance caching in an interview?

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

Correct answer

C. They can cache instances to improve performance.

Why

Static factory methods can cache instances, which can be reused to improve performance, especially in scenarios where the same instance can be used multiple times.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →