InterviewSolution
Saved Bookmarks
| 1. |
Which among the following would destroy the encapsulation mechanism if it was allowed in programming?(a) Using access declaration for private members of base class(b) Using access declaration for public members of base class(c) Using access declaration for local variable of main() function(d) Using access declaration for global variablesI had been asked this question during an interview for a job.This intriguing question comes from Encapsulation topic in section OOPs Concept & Features of Object Oriented Programming |
|
Answer» RIGHT option is (a) Using access declaration for private MEMBERS of base class The best I can explain: If using access declaration for private members of base class was allowed in programming, it would have destroyed whole CONCEPT of encapsulation. As if it was possible, any class which gets inherited PRIVATELY, would have been able to inherit the private members of base class, and hence could access each and EVERY member of base class. |
|