1.

If protected members are to be accessed from outside the class then__________(a) Members must be inherited publicly in subclass(b) Members must accessed using class pointers(c) Members must be accessed as usual(d) Members must be made publicThe question was posed to me during an online interview.Origin of the question is Protected Access Specifier topic in portion Access Specifiers of Object Oriented Programming

Answer»

Right option is (d) MEMBERS MUST be made public

To explain I would say: The members must be made public, otherwise it is not possible. In every CASE, the protected members will act as private members if it’s about access specifier. It will only be inherited, that too will lead to make those members protected again, in SUBCLASSES.



Discussion

No Comment Found

Related InterviewSolutions