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!