Overloading in C ++ Programming MCQ Questions and Answers

1. Which of the following best defines function overloading in C++?
A) Using one function name for functions in different classes
B) Having functions with identical names and identical parameters
C) Having multiple functions with the same name but different parameter lists
D) Using functions with different return types
Answer: C

2. Function overloading in C++ is resolved at:
A) Runtime
B) Compile time
C) Link time
D) Execution time
Answer: B

3. Which of the following cannot be changed during function overloading?
A) Number of parameters
B) Type of parameters
C) Order of parameters
D) Return type only
Answer: D

4. What is operator overloading in C++?
A) Using operators for multiple data types
B) Redefining existing operators for user-defined data types
C) Writing multiple operators with same name
D) Creating new operators in C++
Answer: B

5. Which operator cannot be overloaded in C++?
A) +
B) =
C) []
D) . (dot operator)
Answer: D

6. Function overloading improves:
A) Memory usage
B) Execution speed
C) Code readability and reusability
D) Security
Answer: C

7. Operator overloading provides:
A) Polymorphism
B) Encapsulation
C) Abstraction
D) Inheritance
Answer: A

8. Which keyword is used to define an operator overload?
A) operator
B) overload
C) redefine
D) modify
Answer: A

9. Which among the following operators can be overloaded as a member or non-member function?
A) =
B) []
C) ()
D) +
Answer: D

10. Which operator must be overloaded as a member function?
A) +
B) –
C) =
D) *
Answer: C

11. When two functions have the same name and parameters but different return types, it is:
A) Valid overloading
B) Invalid overloading
C) Runtime overloading
D) Overriding
Answer: B

12. Which function declaration correctly overloads the function add?
A) int add(int, int); and int add(int, int);
B) int add(int, int); and float add(int, int);
C) int add(int, int); and float add(float, float);
D) Both A and C
Answer: C

13. Overloading helps in implementing which concept of OOP?
A) Compile-time polymorphism
B) Dynamic binding
C) Encapsulation
D) Late binding
Answer: A

14. Which of the following cannot be overloaded as a friend function?
A) +
B) –
C) *
D) =
Answer: D

15. What is the return type of overloaded insertion operator (<<) for a class?
A) void
B) ostream
C) ostream&
D) int
Answer: C

16. Function overloading is an example of:
A) Static polymorphism
B) Dynamic polymorphism
C) Data abstraction
D) Encapsulation
Answer: A

17. Which operator can be overloaded to compare two objects?
A) ==
B) &&
C) ||
D) !
Answer: A

18. Which of these functions can be overloaded in C++?
A) Constructors
B) Destructors
C) Both
D) Neither
Answer: A

19. What happens if overloaded functions have ambiguous matches?
A) Compiler selects the first one
B) Compiler ignores others
C) Compiler error occurs
D) Undefined behavior
Answer: C

20. Which of the following cannot be overloaded?
A) ++
B) sizeof
C) ==
D) []
Answer: B

21. What is the syntax for overloading the unary minus operator for a class Point?
A) void operator-(Point);
B) Point operator-();
C) void operator-(int);
D) Point operator-(Point);
Answer: B

22. The friend function used for operator overloading:
A) Has access to private members of the class
B) Cannot access class members
C) Can be called only inside class
D) Must return void
Answer: A

23. Function overloading differs from function overriding because:
A) Both occur at runtime
B) Both occur at compile time
C) Overloading is compile-time, overriding is runtime
D) Both depend on inheritance
Answer: C

24. Which of the following is true about overloaded constructors?
A) They allow objects to be initialized in different ways
B) They cannot use default arguments
C) There can be only one constructor
D) They must return int
Answer: A

25. Operator overloading should not violate:
A) Class visibility
B) Data abstraction
C) Operator semantics and expected behavior
D) Function naming convention
Answer: C

26. Which of the following operators can be overloaded as both member and non-member function?
A) +
B) =
C) []
D) ()
Answer: A

27. When overloading an operator using a friend function, how many parameters does it take for a binary operator?
A) 0
B) 2
C) 1
D) 3
Answer: B

28. Which of the following is not a valid reason to overload operators?
A) To enhance code readability
B) To implement user-defined data operations
C) To change operator precedence
D) To make objects behave like primitive types
Answer: C

29. Function overloading is also called:
A) Runtime binding
B) Compile-time polymorphism
C) Early overriding
D) Static inheritance
Answer: B

30. Which operator cannot be overloaded as a friend function?
A) +
B) –
C) *
D) =
Answer: D

31. When overloading the insertion (<<) operator, which stream class is generally used?
A) ifstream
B) istream
C) ostream
D) streambuf
Answer: C

32. The function signature in overloading includes:
A) Function name only
B) Function name and return type
C) Function name and parameter list
D) Function name, return type, and body
Answer: C

33. Function overloading allows:
A) Functions with same name but different body
B) Functions with same name but different parameter lists
C) Functions with same name and return type only
D) Functions with same name in different namespaces
Answer: B

34. Which among the following cannot be overloaded in C++?
A) ++
B) &&
C) ?:
D) ->
Answer: C

35. The overloaded assignment operator = should generally return:
A) void
B) bool
C) *Reference to the object (this)
D) Integer
Answer: C

36. Overloading of function templates is based on:
A) Argument types and number of parameters
B) Return type
C) Template name
D) Access specifier
Answer: A

37. Operator overloading provides a way to:
A) Create new operators
B) Redefine behavior of existing operators for objects
C) Eliminate need for constructors
D) Avoid inheritance
Answer: B

38. Function overloading cannot be based on:
A) Number of parameters
B) Type of parameters
C) Return type of function
D) Order of parameters
Answer: C

39. Which operator can be overloaded to access elements in an array-like object?
A) ()
B) []
C) ->
D) <<
Answer: B

40. The default copy constructor performs:
A) Shallow copy
B) Member-wise copy
C) Deep copy
D) Bitwise XOR copy
Answer: B

41. If both a default argument and an overloaded version exist for a function, which one takes precedence?
A) Default argument
B) Exact match overload
C) Depends on return type
D) Compiler decides randomly
Answer: B

42. When the operator function is a member function, how many operands are passed explicitly for a binary operator?
A) 0
B) 1
C) 2
D) 3
Answer: B

43. What is true about constructor overloading?
A) Constructors cannot be overloaded
B) Only one constructor allowed
C) Multiple constructors can exist with different parameter lists
D) Constructors must return a value
Answer: C

44. Which of the following represents an overloaded postfix increment operator for a class Count?
A) Count operator++();
B) Count operator++(int);
C) void operator++(Count);
D) int operator++(Count);
Answer: B

45. The compiler differentiates overloaded functions based on:
A) Function body
B) Parameter types and number
C) Variable names inside function
D) Return types only
Answer: B

46. The overloaded extraction operator (>>) must be defined as:
A) Friend function
B) Inline member function
C) Virtual function
D) Static function
Answer: A

47. If two functions differ only by return type, it will cause:
A) Valid overloading
B) Function hiding
C) Compiler error
D) Runtime ambiguity
Answer: C

48. The operator keyword in C++ is used:
A) To create a new operator
B) To define operator overloading function
C) To mark overloaded functions
D) For inheritance
Answer: B

49. What does Point operator+(Point, Point); represent?
A) Member operator function
B) Non-member (friend) operator function
C) Inline operator
D) Static operator
Answer: B

50. Which of the following is true about operator overloading restrictions?
A) Operators can change precedence
B) Operators cannot create new symbols or precedence
C) All operators can be overloaded
D) Only binary operators can be overloaded
Answer: B

51. What is true about overloaded functions in C++?
A) They must have the same return type
B) They must differ in their parameter list
C) They must be defined in different files
D) They must be virtual functions
Answer: B

52. Which operator cannot be overloaded to work with built-in data types?
A) +
B) –
C) *
D) New operators cannot be created for built-in types
Answer: D

53. The overloading of operator() in a class allows:
A) Accessing private members
B) Objects to be called like functions
C) Inheritance of operator behavior
D) Use of object as pointer
Answer: B

54. What will happen if an overloaded operator function does not return a value?
A) Code executes normally
B) Undefined or erroneous behavior
C) The compiler automatically fixes it
D) It converts to void function
Answer: B

55. The syntax Complex operator+(const Complex& c); indicates:
A) Overloading of + operator as a member function
B) Overloading as a non-member function
C) Default operator overloading
D) Friend operator
Answer: A

56. Overloading the output operator (<<) for a class must use which return type?
A) ostream
B) ostream&
C) string
D) void
Answer: B

57. What is the main limitation of function overloading?
A) It increases code length
B) Ambiguity may occur when parameters match multiple overloads
C) Only two functions can be overloaded
D) It cannot be used in classes
Answer: B

58. Which operator cannot be overloaded to work with objects directly?
A) ->
B) ++
C) []
D) sizeof
Answer: D

59. What is the difference between overloading and overriding?
A) Both occur at runtime
B) Overloading occurs in the same scope; overriding occurs in inheritance
C) Overriding is compile-time polymorphism
D) Both depend on virtual keyword
Answer: B

60. The return type of overloaded operator-> must be:
A) Pointer type
B) Reference type
C) Integer
D) Float
Answer: A

61. When a unary operator is overloaded as a member function, it takes:
A) No explicit arguments
B) One explicit argument
C) Two arguments
D) It depends on the operator
Answer: A

62. When a unary operator is overloaded as a non-member function, it takes:
A) No arguments
B) One argument (the operand)
C) Two arguments
D) Three arguments
Answer: B

63. What is function hiding in C++ related to overloading?
A) Overloaded function hiding the base version
B) Base class function being hidden by a derived class function of the same name
C) Runtime overriding
D) Operator masking
Answer: B

64. Can constructors be overloaded with default arguments?
A) No, default arguments are not allowed
B) Only for static objects
C) Yes, if ambiguity does not occur
D) Only one default argument allowed
Answer: C

65. When overloading an operator, which principle should be preserved?
A) Complexity
B) Intuitive behavior similar to built-in operators
C) Reduced code readability
D) Type dependency
Answer: B

66. Which operator can be overloaded only as a member function?
A) +
B) []
C) =
D) <<
Answer: C

67. When you overload the equality operator (==), it must return:
A) int
B) bool
C) void
D) double
Answer: B

68. Which operator can be overloaded for object comparison?
A) <
B) +
C) *
D) %
Answer: A

69. Operator overloading in C++ must not:
A) Use operator keyword
B) Alter operator precedence or associativity
C) Use class members
D) Return values
Answer: B

70. In function overloading, what determines which function gets called?
A) The number and types of arguments passed
B) Return type
C) Function body size
D) Variable scope
Answer: A

71. Which of the following statements is true about operator overloading?
A) It changes the internal meaning of C++
B) It extends the meaning of existing operators for user-defined types
C) It defines new operators in the language
D) It hides built-in operators
Answer: B

72. Which operator can be overloaded for stream extraction?
A) <<
B) >>
C) ==
D) &&
Answer: B

73. What will be the result if multiple overloaded functions match a call equally well?
A) The first one is chosen
B) The last one is chosen
C) Compiler error due to ambiguity
D) The default version is chosen
Answer: C

74. Which of these can be overloaded for an object of class String to support concatenation?
A) –
B) /
C) *
D) +
Answer: D

75. Which among these cannot be overloaded in C++?
A) +
B) ->
C) []
D) :: (scope resolution operator)
Answer: D

76. Which of the following operator functions must be a member function?
A) =
B) +
C) ==
D) <<
Answer: A

77. Function overloading is an example of which OOP concept?
A) Polymorphism
B) Inheritance
C) Abstraction
D) Encapsulation
Answer: A

78. What is the advantage of operator overloading?
A) Slows down the program
B) Improves code readability by allowing natural operations on objects
C) Adds new operators to C++
D) Increases compilation time
Answer: B

79. The overloaded operator-> should return:
A) Object itself
B) Pointer to object or a member
C) Reference to object
D) void
Answer: B

80. Which of the following cannot be overloaded as either member or friend?
A) +
B) –
C) []
D) ::
Answer: D

81. When you overload the function void print(int); with void print(float);, it is an example of:
A) Function overriding
B) Function overloading
C) Operator overloading
D) Virtual dispatch
Answer: B

82. What does the compiler use to differentiate between overloaded functions?
A) Function body
B) Function name
C) Function signature (parameter types and count)
D) Return type only
Answer: C

83. Operator overloading functions can be:
A) Member functions only
B) Non-member functions only
C) Either member or non-member functions
D) Inline only
Answer: C

84. Which operator cannot be overloaded using a non-member function?
A) +
B) –
C) *
D) =
Answer: D

85. When two overloaded functions have the same number of arguments but different data types, which one is called?
A) The first defined one
B) The one with return type match
C) The one with best type match for arguments
D) Randomly chosen
Answer: C

86. If a function is overloaded with default arguments, what must be ensured?
A) Return type differs
B) No ambiguity arises during function calls
C) Different access specifiers used
D) Function names differ
Answer: B

87. Which operator must return a reference when overloaded to support assignment chaining?
A) +
B) ==
C) *
D) =
Answer: D

88. What is the correct declaration for overloading unary minus operator as a member function?
A) void operator-();
B) ClassName operator-();
C) int operator-();
D) operator-(ClassName);
Answer: B

89. When an overloaded operator is defined as a friend function, what is true?
A) It cannot access private data
B) It takes operands as arguments
C) It has implicit this pointer
D) It must be virtual
Answer: B

90. Which among these is true about function overloading and templates?
A) Function overloading replaces templates
B) Templates and overloading can coexist
C) Templates prevent overloading
D) Templates override overloaded functions
Answer: B

91. Which of the following statements is true about operator overloading?
A) It allows creating new operators
B) It changes the grammar of C++
C) It redefines existing operators for user-defined types
D) It changes operator precedence
Answer: C

92. If both member and non-member operator overloads exist for the same operator, which one gets called?
A) Non-member always
B) Member function if applicable
C) Both get called
D) Depends on friend keyword
Answer: B

93. Which operator is commonly overloaded for inputting objects from user?
A) >>
B) <<
C) ()
D) []
Answer: A

94. The overloaded increment operator (++) should ideally return:
A) int
B) Object (or reference) of the same class
C) void
D) float
Answer: B

95. Overloading operator() in a class can make an object behave like:
A) Constant
B) Function
C) Reference
D) Array
Answer: B

96. Which statement is false about operator overloading?
A) It allows existing operators to work with class objects
B) It can change the number of operands for an operator
C) It can improve code readability
D) It can make user-defined types act like primitives
Answer: B

97. Function overloading cannot be achieved by changing:
A) Parameter order
B) Number of parameters
C) Return type only
D) Parameter types
Answer: C

98. What is the output type of an overloaded insertion (<<) operator function?
A) void
B) ostream
C) ostream&
D) string
Answer: C

99. What kind of polymorphism does operator overloading represent?
A) Static (compile-time) polymorphism
B) Dynamic (runtime) polymorphism
C) Late binding polymorphism
D) Pure virtual polymorphism
Answer: A

100. Which of the following best describes function overloading?
A) Multiple functions with the same name and return type
B) Multiple functions with the same name and same parameters
C) Multiple functions with the same name but different parameter lists
D) Functions defined in different namespaces
Answer: C