Question 20Asked in UGC NET Computer Science, June 2016 (Paper II & III, Selected Questions)

Which one of the following is correct, when a class grants friend status to another class?

  1. AThe member functions of the class generating friendship can access the members of the friend class.
  2. BAll member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.
  3. CClass friendship is reciprocal to each other.
  4. DThere is no such concept.
Show answerHide answer

Correct answer: (B) All member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.

Explanation

The member functions of a class which is given friend status by another class can access all private, protected and public members of the class granting friendship. Class friendship is neither reciprocal (commutative) nor transitive unless explicitly specified.

From UGC NET Computer Science PYQ, June 2016 (Paper II & III, Selected Questions)

This is question 20 of UGC NET Computer Science PYQ, June 2016 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.