Question 17337 – NTA UGC NET Dec 2023 Paper-1
March 22, 2024NTA UGC NET Dec 2023 Paper-2
March 22, 2024NTA 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
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
Both Statement I and Statement II are correct | |
Both Statement 1 and Statement II are incorrect | |
Statement is correct but Statement II is incorrect | |
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.
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.
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.
Subscribe
Login
0 Comments