Users Online

· Guests Online: 49

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

C# Questions & Answers ? Introduction of Overloaded Operators

C# Questions & Answers – Introduction of Overloaded Operators

 

 

 

This set of C# test focuses on “Introduction of Overloaded Operators”.

 

 

 

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
Explanation: None.

 

 

 

2. Which of the 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
Explanation: None.

 

 

 

 

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
Explanation: None.

 

 

 

 

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
Explanation: None.

 

 

 

6. Correct way to define operator method or to perform operator overloading is?
a)

  1.    public static op(arglist)
  2.    {
  3.  
  4.    }

b)

  1.    public static retval op(arglist)
  2.    {
  3.  
  4.    }

c)

  1.    public static retval operator op(arglist)
  2.    {
  3.  
  4.    }

d) All of the mentioned

Answer: c
Explanation: None.

 

 

 

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
Explanation: None.

 

 

 

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
Explanation: None

 

 

 

9. What is the 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
Explanation: None.

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.83 seconds
10,842,308 unique visits