Skip to content
Sharp

Modern Java · interview question

Which of the following statements is true about static factory methods?

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

Correct answer

C. They can control the number of instances.

Why

Static factory methods can control the number of instances by returning cached objects instead of creating new ones, which can be a significant advantage over constructors.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →