LearnFrenzy
Sign in Take a free test

Constructors and the this Keyword · Constructors MCQ · Question 16

Advantages of static factory methods Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 16 Back to Exercise

Which is an advantage of a static factory method over a constructor?

  • A It always creates a new object
  • B It can have a descriptive name and can return cached objects or a subtype Correct
  • C It runs faster
  • D It can be overridden
Correct Answer: Option B

Integer.valueOf caches small values; List.of returns an internal immutable type.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links