1.

While inheriting a class, if no access mode is specified, then which among the following is true? (in C++)(a) It gets inherited publicly by default(b) It gets inherited protected by default(c) It gets inherited privately by default(d) It is not possibleThe question was posed to me in class test.The origin of the question is Inheritance topic in chapter Inheritance & its Types of Object Oriented Programming

Answer»

The correct ANSWER is (c) It GETS inherited privately by DEFAULT

Explanation: If the ACCESS mode is not specified during inheritance, the class is inherited privately by default. This is to ensure the security of data and to maintain OOP features. Hence it is not mandatory to specify the access mode if we want the class to be inherited privately.



Discussion

No Comment Found

Related InterviewSolutions