Explore topic-wise MCQs in Technical MCQs.

This section includes 7 Mcqs, each offering curated multiple-choice questions to sharpen your Technical MCQs knowledge and support exam preparation. Choose a topic below to get started.

1.

Where does keyword ‘friend’ should be placed?

A. function declaration
B. function definition
C. main function
D. block function
E.
Answer» B. function definition
2.

class Box{ int capacity;   public: void print(); friend void show(); bool compare(); friend bool lost();};
7.Which keyword is used to represent a friend function?

A. friend
B. Friend
C. friend_func
D. Friend_func
Answer» B. Friend
3.

#include <iostream>class A { private:     int a;   public:     A() { a = 0; }     friend class B; // Friend Class };   class B { private:     int b;   public:     void showA(A& x)     {                  std::cout << ""A::a="" << x.a;     } };   int main() {     A a;     B b;     b.showA(a);    }
6.What will be output for the following code?

A. 1
B. 2
C. 3
D. 4
Answer» C. 3
4.

What will be output for the followiing code?

A. A::a=0
B. A
C. a=0
D. A::0
Answer» B. A
5.

If class A is a friend of B, then B doesn’t become a friend of A automatically.

A. TRUE
B. FALSE
C. Can be true and false
D. Can not say
Answer» B. FALSE
6.

A friend function can be

A. A method of another class
B. A global function
C. Both A and B
D. None of the above
Answer» D. None of the above
7.

A friend class can access ____________________ members of other class in which it is declared as friend.

A. private
B. protected
C. public
D. Both A and B
Answer» E.