1.

The private members of the base class are visible in derived class but are not accessible directly.(a) True(b) FalseThis question was addressed to me in semester exam.I want to ask this question from Inheritance in division Inheritance & its Types of Object Oriented Programming

Answer»

Right answer is (a) True

To explain I would say: Consider that a variable is PRIVATE in base class and the derived class USES public INHERITANCE to inherit that class. Now if we also have a global variable of same name as that of base class private variable, neither the global variable nor the base class private variable will be accessible from derived class. This is because we can’t have 2 variables with same name in same LOCAL scope. Hence the private members are accessible but not DIRECTLY.



Discussion

No Comment Found

Related InterviewSolutions