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:

This question was previously asked in
UGC NET Computer Science (Paper 2) 07 Dec 2023 Official Paper
View all UGC NET Papers >
  1. Both Statement I and Statement II are correct 
  2. Both Statement I and Statement II are incorrect
  3. Statement I is correct but Statement II is incorrect
  4. Statement I is incorrect but Statement II is correct

Answer (Detailed Solution Below)

Option 3 : Statement I is correct but Statement II is incorrect
Free
UGC NET Paper 1: Held on 21st August 2024 Shift 1
16.3 K Users
50 Questions 100 Marks 60 Mins

Detailed Solution

Download Solution PDF

The correct answer is option 3: Statement I is correct but Statement II is incorrect

Key Points

  • Friend Function: A friend function in C++ is a function that is not a member of a class but has access to its private and protected members. It is declared using the keyword friend inside the class.
  • Friend Class: All member functions of a friend class can directly access private and protected members of the class that declared it as a friend.

Statement I: TRUE ✅

  • The friend function and member functions of a friend class can directly access the private and protected data of the class in which they are declared as friend.
  • This is by definition of friendship in C++.

Statement II: FALSE ❌

  • A friend function does not need to go through member functions of the base class to access private members.
  • It either has direct access (if declared friend), or it doesn’t have access at all.
  • Also, friend functions are not inherited through base classes — so they don't have privileged access via base class methods unless explicitly declared as friend in that class.

Hence, only Statement I is correct.

Final Answer: Option 3) Statement I is correct but Statement II is incorrect

Latest UGC NET Updates

Last updated on Jul 7, 2025

-> The UGC NET Answer Key 2025 June was released on the official website ugcnet.nta.ac.in on 06th July 2025.

-> The UGC NET June 2025 exam will be conducted from 25th to 29th June 2025.

-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.

-> The exam is conducted bi-annually - in June and December cycles.

-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions. 

-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.

More OOPs concept Questions

Get Free Access Now
Hot Links: teen patti master download teen patti master plus teen patti circle teen patti customer care number teen patti classic