Question 49

Consider the following Inheritance in C++ : class Person

Consider the following Inheritance in C++ : class Person { char AadharNo[12]; protected : char Name[20]; public : ______ ______ void Readdata( ); }; class Student : public Person { int Grade; public : ______ ______ }; What will be the visibility mode of Name and Readdata ( ) in the derived class student ?
  1. AName → Protected, Readdata → Protected
  2. BName → Protected, Readdata → Public
  3. CName → Private, Readdata → Protected
  4. DName → Public, Readdata → Public
Show answerHide answer

Correct answer: (B) Name → Protected, Readdata → Public

Explanation

With public inheritance, protected members stay protected and public members stay public in the derived class. So Name is protected and Readdata() is public. The private AadharNo is not accessible in Student.

From DSSSB TGT Computer Science Practice Set 3

This is question 49 of DSSSB TGT Computer Science Practice Set 3. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.