Advertisements
Advertisements
Question
Differentiate between private and protected visibility modifiers.
Distinguish Between
Solution
S. No. | Private | Protected |
1. | Private members are only visible within the class where they were defined. | Protected members are visible to classes within the same package and to subclasses (including those from other packages). |
2. | Private elements are not shared with other classes during inheritance. | Protected elements can be applied to derived classes during inheritance. |
shaalaa.com
Is there an error in this question or solution?