TypeScript · Middle · Question 13 of 75
How does protected differ from private in TypeScript classes?
- ✓Correct answer:
protectedis accessible in subclasses,privateonly in the class itself - 2
protectedis readable from outside, whileprivateisn't - 3They're synonyms;
protectedis the old name
Explanation
public (the default) is accessible everywhere, protected in the class and its subclasses, private only in the declaring class. All three are compiler checks; for real runtime privacy there's #field.