Site icon T4Tutorials.com

Friend function MCQs – C++

1. We can define a binary operator as:

(A) The operator that performs its action on two operands


(B) The operator that performs its action on three operands


(C) The operator that performs its action on any number of operands


(D) The operator that performs its action on a single operand



2. Correct example of a binary operator is _______.

(A) —


(B) +


(C) ++


(D) Dereferencing operator (*)



3. ____ is a correct example of a unary operator.

(A) /


(B) —


(C) &


(D) ==



4. When we use an operator on user-defined class objects, operator overloading:

(A) Always be used must


(B) Never be used must


(C) With three exceptions must never be used


(D) With three exceptions must always be used



5. Ternary operator is shown as _____.

(A) ===


(B) &&


(C) ?:


(D) |||



6. Overloading the addition (+) operator is correct function name OF:

(A) operator(+)


(B) operator_+


(C) operator+


(D) operator:+



7. ________ operators cannot be overloaded?

(A) The [ ] operator


operator” onclick=”checkAnswer(‘q7’, ‘The . operator’)”> (B) The -> operator


(C) The . operator


(D) The & operator



8. Choose the correct statement which is false about the operator:

(A) Overloading cannot change how an operator works on built-in types


(B) New operators can never be created


(C) The precedence of an operator cannot be changed by overloading


(D) Operators can change the number of arguments certain overloaded they take



9. To implicitly overload the += operator:

(A) Only the = operator needs to be overloaded


(B) Only the + operator needs to be overloaded


(C) The += operator cannot be overloaded implicitly


(D) Both the + and = operators need to be overloaded



 

friend function declaration and definition
friend function declaration and definition

 

C++ example with a program with friend function
C++ example with a program with friend function

 

Example of Friend function Can access private and protected data members in C++
Example of Friend function Can access private and protected data members in C++

Friend Class in CPP

 

Friend functionality is not restricted to only one class
Friend functionality is not restricted to only one class

 

friend function cannot be invoked using the object as it is not in the scope of that class
friend functions cannot be invoked using the object as it is not in the scope of that class

 

Example of Friend functions having objects as arguments
Example of Friend functions having objects as arguments

OOP MCQs 

Programming C Plus Plus MCQs Homepage

shamil memory table

Exit mobile version