C# Questions & Answers on Introduction of Overloaded Operators for Freshers

1. Which of the following keyword is used to overload user defined types by defining static member functions?

a) op
b) opoverload
c) operator
d) operatoroverload
Answer: c
2. Which of following statements are correct in nature?

a) The conditional logical operators cannot be overloaded
b) The array indexing operator can be overloaded
c) A public or nested public preference type does not overload the equality operator
d) None of the mentioned
Answer: a
3. Arrange the following overloaded operators in increasing order of precedence?
%, <<, &, /, +

a) ‘%’ < ‘<<‘ < ‘+’ < ‘-‘ < ‘&’ < ‘/’
b) ‘<<‘ < ‘&’ < ‘%’ < ‘-‘ < ‘/’ < ‘+’
c) ‘&’ < ‘-‘ <‘%’ < ‘<<‘ < ‘/’ < ‘+’
d) ‘/’ < ‘-‘ < ‘%’ < ‘+’ < ‘<<‘ < ‘&’
Answer: b
4. Operators that can be overloaded are?

a) ||
b) ‘+=’
c) +
d) [].
Answer: c
5. Which statements are correct about operator overloading?

a) Mathematical or physical modeling where we use classes to represent objects such as vectors,matrices,complex-numbers etc
b) Graphical programs where coordinate related objects are used to represent positions on the screen
c) Financial programs where a class represents an amount of money
d) All of the mentioned
Answer: d
6. Correct way to define operator method or to perform operator overloading is?
  1. a) public static op(arglist)
  2.    {
  3.  
  4.    }
  5. b) public static retval op(arglist)
  6.    {
  7.  
  8.    }
  9. c) public static retval operator op(arglist)
  10.    {
  11.  
  12.    }
  13. d) All of the mentioned

Answer: c

7. Correct method to define + operator is?

a) public sample operator +(int a, int b)
b) public abstract operator +(int a, int b)
c) public static sample operator +(int a, int b)
d) public abstract sample operator +(int a, int b)
Answer: c
8. Choose the correct statement among the below mentioned statements:

a) Forgetting to declare an operator method as public
b) Forgetting to declare an operator method as static
c) Forgetting to return a bool type value while overloading a relational operator
d) All of the mentioned
Answer: d
9. What is vector in operator overloading?

a) class
b) method()
c) data type
d) none of the mentioned
Answer: c

Explanation: It is a data type of class . It is defined as : public static Vector operator + (Vector a, Vector b).
10. Choose the wrong statement from the given set of statements?

a) All operators in C#.NET cannot be overloaded
b) We can use the new modifier to modify a nested type if the nested type is hiding another type
c) Operator overloading permits the use of symbols to represent computations for a type
d) In case of operator overloading all parameters must be of different type than the class or struct that declares the operators
Answer: d

Related

Multiple Choice Questions 4742254437712678086

Post a Comment

emo-but-icon

item