Software-Engineering
October 6, 2023
2011 December UGC NET Paper 1
October 6, 2023
Software-Engineering
October 6, 2023
2011 December UGC NET Paper 1
October 6, 2023

OOPS

Question 12
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?
A
Member function of class B can access protected data of class A
B
Member function of class access public data of class A
C
Member function of class B cannot access private data of class A
D
Object of derived class B can access public base class data
Question 12 Explanation: 
A→ Base class
B→ Derived class from A with protected inheritance.
The friend functions and the member functions of a friend class can have direct access to both the PRIVATE and PROTECTED data, the member functions of a derived class can directly access only the PROTECTED data.
However, they can access the PRIVATE data through the member functions of the base class
TRUE: Member function of class B can access protected data of class A
TRUE: Member function of class access public data of class A
FALSE: Member function of class B cannot access private data of class A
TRUE: Object of derived class B can access public base class data

Correct Answer: D
Question 12 Explanation: 
A→ Base class
B→ Derived class from A with protected inheritance.
The friend functions and the member functions of a friend class can have direct access to both the PRIVATE and PROTECTED data, the member functions of a derived class can directly access only the PROTECTED data.
However, they can access the PRIVATE data through the member functions of the base class
TRUE: Member function of class B can access protected data of class A
TRUE: Member function of class access public data of class A
FALSE: Member function of class B cannot access private data of class A
TRUE: Object of derived class B can access public base class data

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!