Multiple choice general knowledge science & technology

Which of the following denotes advantages of operator overloading ?

  1. Extensibility

  2. Operator not limited to operate only with primitive Data Type

  3. Both A and B

  4. Operator's Scope is increased

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Operator overloading allows operators to work with user-defined types (extensibility) and means operators are not limited to primitive data types only. Both statements A and B are correct advantages, making 'Both A and B' the right answer. Option D about increased scope is vague - the scope isn't increased but rather extended to work with custom types.

AI explanation

To answer this question, we need to understand the concept of operator overloading and its advantages.

Operator overloading allows us to redefine the behavior of an operator for user-defined types. This means that we can provide a specific implementation for an operator when it is used with our own custom data types.

Now let's go through each option to understand why it is correct or incorrect:

Option A) Extensibility - This option is correct because operator overloading allows us to extend the functionality of existing operators to work with user-defined types. This means that we can define how operators should behave when used with our own classes or structures.

Option B) Operator not limited to operate only with primitive Data Type - This option is correct because operator overloading allows us to use operators with user-defined types, not just with primitive data types. This provides flexibility and allows us to define specific behavior for operators when used with our own data types.

Option C) Both A and B - This option is correct because both extensibility and the ability to use operators with user-defined types are advantages of operator overloading.

Option D) Operator's Scope is increased - This option is incorrect because operator overloading does not increase the scope of operators. It only allows us to define specific behavior for operators when used with our own data types.

Therefore, the correct answer is C) Both A and B.