C Sharp Operators Questions and Answers

Take Exam

In C# programming, operators are fundamental elements used to perform arithmetic, logical, comparison, and bitwise operations. Mastering programming questions and answers on C# operators is crucial for interviews at TCS, Infosys, and Wipro. Understanding operator precedence, associativity, and overloading enhances your coding accuracy and debugging skills. These C programming MCQ and C# operator questions test your ability to manipulate data efficiently. Practice programming interview questions with answers to strengthen your C# fundamentals for competitive coding assessments and placement tests.

Study operators and assignments in C#. Also explore C# control instructions and C# arrays

C Sharp Operators

Showing 10 of 19 questions

1. Which of the following are the correct ways to increment the value of variable a by 1?     1.    ++a++;     2.      a += 1;     3.    a ++ 1;     4.    a = a +1;     5.    a = +1;

  • 1, 3
  • 2, 4
  • 3, 5
  • 4, 5
Show Answer Report

2. What will be the output of the C#.NET code snippet given below? byte b1 = 0xF7; byte b2 = 0xAB; byte temp; temp = (byte)(b1 & b2); Console.Write (temp + " "); temp = (byte)(b1^b2); Console.WriteLine(temp);

  • 163 92
  • 92 163
  • 192 63
  • 0 1
Show Answer Report

3. Which of the following is NOT an Arithmetic operator in C#.NET?

  • **
  • +
  • /
  • %
Show Answer Report

4. Which of the following are NOT Relational operators in C#.NET? >=     !=     Not     <=     <>=

  • 1, 3
  • 2, 4
  • 3, 5
  • 4, 5
Show Answer Report

5. Which of the following is NOT a Bitwise operator in C#.NET?

  • &
  • |
  • <<
  • ^
Show Answer Report

6. Which of the following statements is correct about the C#.NET code snippet given below? int d; d = Convert.Tolnt32( !(30 &lt; 20) );

  • A value 0 will be assigned to d.
  • A value 1 will be assigned to d.
  • A value -1 will be assigned to d.
  • The code reports an error.
Show Answer Report

7. Which of the following is the correct output for the C#.NET code snippet given below? Console.WriteLine(13 / 2 + &quot; &quot; + 13 % 2);

  • 6.5 1
  • 6.5 0
  • 6 0
  • 6 1
Show Answer Report

8. Which of the following statements are correct about the Bitwise &amp; operator used in C#.NET? The &amp; operator can be used to Invert a bit. &nbsp;&nbsp;&nbsp; The &amp; operator can be used to put ON a bit. &nbsp;&nbsp;&nbsp; The &amp; operator can be used to put OFF a bit. &nbsp;&nbsp;&nbsp; The &amp; operator can be used to check whether a bit is ON. &nbsp;&nbsp;&nbsp; The &amp; operator can be used to check whether a bit is OFF.

  • 1, 2, 4
  • 2, 3, 5
  • 3, 4
  • 3, 4, 5
Show Answer Report

9. Which of the following are Logical operators in C#.NET? &nbsp;&nbsp;&nbsp; &amp;&amp; &nbsp;&nbsp;&nbsp; || &nbsp;&nbsp;&nbsp; ! &nbsp;&nbsp;&nbsp; Xor &nbsp;&nbsp;&nbsp; %

  • 1, 2, 3
  • 1, 3, 4
  • 2, 4, 5
  • 3, 4, 5
Show Answer Report

10. Suppose n is a variable of the type Byte and we wish, to check whether its fourth bit (from right) is ON or OFF. Which of the following statements will do this correctly?

  • if ((n&16) == 16) Console.WriteLine("Third bit is ON");
  • if ((n&8) == 8) Console.WriteLine("Third bit is ON");
  • if ((n ! 8) == 8) Console.WriteLine("Third bit is ON");
  • if ((n ^ 8) == 8) Console.WriteLine("Third bit is ON");
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test