Intermediate
Ruby
Q69 / 100
What is the purpose of the "protected" access modifier compared to "private"?
Correct! Well done.
Incorrect.
The correct answer is B) protected methods can be called with an explicit receiver as long as the caller is an instance of the same class or subclass, while private methods generally cannot be called with an explicit receiver at all
B
Correct Answer
protected methods can be called with an explicit receiver as long as the caller is an instance of the same class or subclass, while private methods generally cannot be called with an explicit receiver at all
Explanation
protected allows calling the method on another object of the same class hierarchy (e.g. comparing two instances), whereas private restricts calls to implicit self only.
Progress
69/100