Wednesday, 3 June 2020

UGC NET Computer Science December 2019 | Question 65

Question 65
Let A be the base class in C++ and B be the derived class from A with protected inheritance. Which of the following statement is false for class B?
  1. 1. Member function of class B can access protected data of class A
  2. 2. Member function of Class B can access public data of class A
  3. 3. Member function of class B cannot access private data of class A
  4. 4. Object of derived class B can access public base class data
Explanation
If protected access specifier is used while deriving class then the public and protected data members of the base class becomes the protected member of the derived class and private member of the base class are inaccessible.

In this case, the members of the base class can be used only within the derived class as protected members except for the private members.

TRUE: Member function of class B can access protected data of class A
TRUE: Member function of Class B can access public data of class A
TRUE: Member function of class B cannot access private data of class A
FALSE: Object of derived class B can access public base class data

Private and protected member variables of a derived class are not accessed by using direct member access operator

Given option 4 statement is false.

So, option 4 is correct answer

Reference with example: C++ Access Specifiers - Protected Access Specifier


PreviousNext
UGC NET CS December 2019 - Question 64UGC NET CS December 2019 - Question 66

No comments:

Post a Comment

UGC NET Computer Science December 2019 | Question 16

Question 16 In a certain coding language. 'AEIOU' is written as 'TNHDZ'. Using the same coding language. 'BFJPV' wil...

Popular Posts