...
Question 17337 – NTA UGC NET Dec 2023 Paper-1
March 22, 2024
NTA UGC NET Dec 2023 Paper-2
March 22, 2024
Question 17337 – NTA UGC NET Dec 2023 Paper-1
March 22, 2024
NTA UGC NET Dec 2023 Paper-2
March 22, 2024

NTA UGC NET Dec 2023 Paper-2

Question 51
Given below are two statements:
Statement (I) The friend function and the member functions of a friend class directly access the private and protected data.
Statement (II) The friend function can access the private data through the member functions of the base class.
In the light of the above statements, choose the most appropriate answer from the options given below
A
Both Statement I and Statement II are correct
B
Both Statement 1 and Statement II are incorrect
C
Statement is correct but Statement II is incorrect
D
Statement 1 is incorrect but Statement II is correct
Question 51 Explanation: 
Statement (I): “The friend function and the member functions of a friend class directly access the private and protected data.”

This statement is generally correct. In C++, a friend function and the member functions of a friend class can directly access the private and protected data of the class they are friends with.
Statement (II): “The friend function can access the private data through the member functions of the base class.”
This statement is incorrect. A friend function can access the private members of the class it is declared as a friend of, but it does not have automatic access to the private members of the base class. Access to the base class’s private members is subject to the base class’s own access rules.
Correct Answer: C
Question 51 Explanation: 
Statement (I): “The friend function and the member functions of a friend class directly access the private and protected data.”

This statement is generally correct. In C++, a friend function and the member functions of a friend class can directly access the private and protected data of the class they are friends with.
Statement (II): “The friend function can access the private data through the member functions of the base class.”
This statement is incorrect. A friend function can access the private members of the class it is declared as a friend of, but it does not have automatic access to the private members of the base class. Access to the base class’s private members is subject to the base class’s own access rules.
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!!