Question 8
Back to Exercise
Why do constructors often contain this.name = name;?
- A It is required syntax
- B The parameter name hides the field, so this.name is needed to refer to the field Correct
- C It makes the field final
- D It copies the object
Correct Answer: Option B
Without this, name = name assigns the parameter to itself.
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!