Вы находитесь на странице: 1из 6

Operator Overloading

1. .Which of the following operators cannot be overloaded?


A. .* (Pointer-to-member Operator )
B. :: (Scope Resolution Operator)
C. .* (Pointer-to-member Operator )
D. All of the above
D

2. While overloading binary operators using member function, it


requires ___ argument?
A. 2
B. 1
C. 0
D. 3
B

3. What would be the output of the following code?

A. x = 5, y = 10
B. x = 10, y = 5
C. Compiler Error: Ambiguous call
D. No error and No output
B

4.

A. lets(int) called
B. lets(lfc 2) called
C. Compiler Error: Ambiguous call
D. No error and No output
5. A non-member function that is given access to all members of the class within it is declared is called
as

A. Access function

B. Friend function

C. Operator function

D. None of the above

6. Which of the following is the correct order involves in the process of


operator overloading.
i) Define the operator function to implement the required operations.
ii) Create a class that defines the data type that is to be used in the
overloading operation.
iii) Declare the operator function op() in the public part of the class.
A. 1-i, 2-ii, 3-iii
B. 1-ii, 2-iii, 3-i
C. 1-ii, 2-i, 2-iii
D. 1-iii, 2-ii, 3-i
1) We can overload which of the following C++ operators.

A) Arithmetic operator (+, -, *, /)


B) Class Member Access Operators (., .*)
C) Size operator(sizeof)
D) Conditional operator(?:)
A

2) ……………… must be either non-static member function or friend functions.


A) member functions
B) Operator functions
C) non-static functions
D) friend functions
B

3) Operator overloading is also called …………….. polymorphism.


A) run time
B) initial time
C) compile time
D) completion time
C

4) We can overload almost all the C++ operators except the following.
i) Class member operator (.,.*)   ii) Assignment operator (=)
iii) Scope resolution operator (::) iv) Conditional operator (?:)
A) i, ii and iii only
B) ii, iii and iv only
C) i, iii and iv only
D) All i, ii, iii and iv
C

5) Which of the following is the correct order involves in the process of operator overloading.
i) Define the operator function to implement the required operations.
ii) Create a class that defines the data type that is to be used in the overloading operation.
iii) Declare the operator function op() in the public part of the class.
A) 1-i, 2-ii, 3-iii
B) 1-ii, 2-iii, 3-i
C) 1-ii, 2-i, 2-iii
D) 1-iii, 2-ii, 3-i
B

6) State whether the following statements are True or False for overloading operators.
i) Only existing operators can be overloaded.
ii) We can change the basic meaning of an operator
A) True, True
B) True, False
C) False, True
D) False, False
B

7) We cannot use friend functions to overload which of the following operators.


i) membership operator(.)    ii) Assignment operator(=)
iii) class member access operator(_>)  iv) conditional operator(?:)
A) i and ii only
B) ii and iii only
C) iii and iv only
D) i and iv only
B

8) …………… overloaded by means of a member function, take no explicit arguments and return no
explicit values.
A) Unary operators
B) Binary operators
C) Arithmetic operators
D) Function operator
A

9) ……………. overloaded through a member function take one explicit argument and those which are
overloaded through a friend function take two explicit arguments.
A) Unary operators
B) Binary operators
C) Arithmetic operators
D) Function operator
B

10) When using ………………., overloaded through a member function, the left hand operand must be an
object of the relevant class.
A) Unary operators
B) Binary operators
C) Arithmetic operators
D) Function operator
B

11) Operator overloading is done with the help of a special function called ……………, which describes the
special task of an operator.
A) overloading function
B) special task function
C) detail function
D) operator function
D

12) The compiler does not support automatic type conversions for the ………….. data type.
A) basic
B) user defined
C) class
D) automatic
B

13) The casting operator function should satisfy which of the following conditions.
i) It must be a class member    ii) It must not specify return type
iii) It must not have any arguments
A) i and ii only
B) ii and iii only
C) i, iii only
D) All i, ii and iii
D

14) The conversion from a class to any other type or any other class should make use of a ………….. in the
source class.
A) casting operator
B) constructor
C) not applicable
D) operator function
A

15) To perform the conversion from any other data type or class to a class type, a ………….. should be
used in the destination class.
A) casting operator
B) constructor
C) not applicable
D) operator function
B

16) The general form of an overloaded casting operator function usually referred to as a ……………..
A) casting function
B) operator function
C) conversion function
D) overloaded function
C

17) Operator overloading provides a flexible option for the creation of new …………….. for most of the C+
+ operations.
A) class
B) function
C) object
D) definitions
D

18) In the case of …………….. function, arguments may be passed either by value or by reference.
A) private
B) friend
C) member
D) public
B

Вам также может понравиться