Friend Functions and Friend Classes – MCQs July 22, 2025 by u930973931_answers 30 Score: 0 Attempted: 0/30 Subscribe 1. : What is a friend function in C++? (A) A function that can access private and protected members of a class (B) A private function inside a class (C) A function that is always inline (D) A member function of a class 2. : Which keyword is used to declare a friend function? (A) private (B) public (C) friend (D) external 3. : Can a friend function be a member of a class? (A) Yes (B) No (C) Only if it’s static (D) Only in inherited classes 4. : Where is a friend function defined? (A) Inside the class (B) Outside the class (C) Both inside and outside (D) None of the above 5. : Can friend functions access private data members of a class? (A) Yes (B) No (C) Only public members (D) Only static members 6. : Which of the following is true about friend functions? (A) They are inherited (B) They can be called using class objects (C) They do not require object to be called (D) They can access only static members 7. : Can a friend function be declared as virtual? (A) Yes (B) No (C) Only for derived classes (D) Only if static 8. : What is a friend class? (A) A class that inherits another class (B) A class that shares its private members with another class (C) A class that cannot be instantiated (D) A class that contains only friend functions 9. : Which keyword is used to declare a friend class? (A) private (B) protected (C) share (D) friend 10. : What can a friend class access? (A) Only public members (B) All members including private and protected (C) Only static members (D) None 11. : Can a friend function be overloaded? (A) Yes (B) No (C) Only once (D) Only if private 12. : Are friend functions inline by default? (A) Yes (B) No (C) Only static ones (D) Only for constructors 13. : Can a friend function access protected members of a class? (A) Yes (B) No (C) Only in derived classes (D) Only if declared inline 14. : How is a friend function different from a member function? (A) It is defined inside the class (B) It is defined outside the class and not a member (C) It uses the this pointer (D) It is called using object name 15. : Can a friend function of one class be a member of another class? (A) Yes (B) No (C) Only in templates (D) Only static ones 16. : Can a friend function be a global function? (A) Yes (B) No (C) Only within main() (D) Only if virtual 17. : Which access modifier is used with friend functions? (A) friend (B) Any (public, protected, or private) (C) Only public (D) Only private 18. : What is required for a function to be a friend function of a class? (A) It must be declared in the class using the friend keyword (B) It must be a class member (C) It must be private (D) It must be virtual 19. : Can a class declare another class as a friend more than once? (A) Yes (B) No (C) Only in public scope (D) Only if inherited 20. : Are friend functions inherited in derived classes? (A) Yes (B) No (C) Only virtual ones (D) Only private ones 21. : Can a function be friend to more than one class? (A) Yes (B) No (C) Only if static (D) Only if member of another class 22. : Can a friend function be declared in multiple classes? (A) Yes (B) No (C) Only once globally (D) Only for abstract classes 23. : What kind of relationship does a friend function violate in OOP? (A) Encapsulation (B) Inheritance (C) Polymorphism (D) Abstraction 24. : Can a friend function be a template function? (A) Yes (B) No (C) Only for static classes (D) Only for constructors 25. : How many friend classes can a class have? (A) 1 (B) 10 (C) As many as needed (D) None 26. : Where is the friend function prototype written? (A) Inside class definition (B) Inside main() (C) Inside another class (D) In a namespace 27. : How can a friend function be called? (A) Using class name (B) Using object (C) Like a normal function (D) It is called automatically 28. : What is one major drawback of friend functions? (A) Cannot access static members (B) Cannot be inline (C) Violates encapsulation (D) Cannot be overloaded 29. : What is the scope of a friend function? (A) Limited to class (B) Global (C) Local (D) Public only 30. : What is needed to allow a function from one class to access private members of another? (A) Declare the function as static (B) Declare the function as inline (C) Declare it as friend in the target class (D) Make it protected