1.

Which among the following is true?(a) The private members can’t be accessed by public members of the class(b) The private members can be accessed by public members of the class(c) The private members can be accessed only by the private members of the class(d) The private members can’t be accessed by the protected members of the classI have been asked this question in an internship interview.The doubt is from Private Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right ANSWER is (b) The private members can be accessed by public members of the CLASS

Easiest explanation - The private members are accessible within the class. There is no RESTRICTION on use of private members by public or PROTECTED members. All the members can access the private MEMBER functions of the class.



Discussion

No Comment Found

Related InterviewSolutions