C# Programming - Operators - Discussion

Discussion Forum : Operators - General Questions (Q.No. 8)
8.
Which of the following statements are correct about the Bitwise & operator used in C#.NET?
  1. The & operator can be used to Invert a bit.
  2. The & operator can be used to put ON a bit.
  3. The & operator can be used to put OFF a bit.
  4. The & operator can be used to check whether a bit is ON.
  5. The & operator can be used to check whether a bit is OFF.
1, 2, 4
2, 3, 5
3, 4
3, 4, 5
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
9 comments Page 1 of 1.

Bhairav said:   1 decade ago
I am not getting this point please explain ?

Deepika said:   1 decade ago
Please anyone explain?

Amala said:   1 decade ago
Please any one eplain, I am not getting answer.

Rekha said:   1 decade ago
Am not getting this can you please explain me clearly.

Harisan said:   1 decade ago
Explain it.

Tej Pratap said:   1 decade ago
Please explain this question.

Manisha said:   1 decade ago
It means that and is use for the multiplication purpose.
1 1 = 1 means on to checks.
1 0 = 0 off.
0 1 = 0 off.
0 1 = 0 off.

Jay said:   1 decade ago
1st option is WRONG because & operator never works on single bit ,it require minimum 2 bit like ( 1 & 1 = 1 or 1 & 0 = 0), so no hope for 1.

2nd option is WRONG because 1 & 1 = 1 i.e ON. when bits are already ON then it makes no sense.

3rd is CORRECT because 1 & 0 = 0 i.e OFF. it makes sense here. Any one of the bit is OFF then Then results comes OFF.

4th is also CORRECT. when u have a bit ,try to AND it with 1 and if you get result 1 i.e ON then Prev bit was 1 i.e 1


and if you get result 0 (OFF) then but obvious Prev bit was 0 that's why option 5 is also CORRECT

Sumit Sharma said:   1 decade ago
3. If bit is ON means bit=1 by ending this bit with 0 we can OFF this bit i.e 1&0=0.

4 and 5. We can check a bit is ON by ending bit with 1 i.e
If bit&1=1 (bit is ON) else bit is OFF.

So Points 3,4 and 5 are correct.

Post your comments here:

Your comments will be displayed after verification.