1.

Which among the following best describes the protected specifier?(a) Members are most secure and can’t be used outside class(b) Members are secure but can be used outside the class(c) Members are secure as private, but can be inherited(d) Members are secure like private, but can’t be inheritedThe question was asked in an online interview.My question is from Protected Access Specifier topic in chapter Access Specifiers of Object Oriented Programming

Answer»

The correct option is (c) MEMBERS are secure as private, but can be inherited

The BEST explanation: The members which are made protected, are most secure if INHERITANCE is not used. But, this facility is provided to keep those members private and with that, they can be inherited by other classes. This is done to MAKE the CODE more flexible.



Discussion

No Comment Found

Related InterviewSolutions