Java Programming - Operators and Assignments - Discussion

Discussion Forum : Operators and Assignments - Pointing out the correct statements (Q.No. 3)
3.
Which two statements are equivalent?
  1. 16*4
  2. 16>>2
  3. 16/2^2
  4. 16>>>2
1 and 2
2 and 4
3 and 4
1 and 3
Answer: Option
Explanation:

(2) is correct. 16 >> 2 = 4

(4) is correct. 16 >>> 2 = 4

(1) is wrong. 16 * 4 = 64

(3) is wrong. 16/2 ^ 2 = 10

Discussion:
27 comments Page 3 of 3.

BIKASH DEY said:   1 decade ago
Can any one tell me mathematically how is 16/2 ^ 2 = 10.

Rohan said:   1 decade ago
Thanks Jose.

Anil said:   1 decade ago
In binary 16 is 10000, now shift the bits two places to the right (>>2)and we get 100 which is 4

In binary 16 is 10000, now shift the bits three places to the right (>>>2)and we get 10 which is 2

So how the 2 and 4 is correct?

Khyati said:   1 decade ago
In binary 16 is 10000, now shift the bits two places to the right (>>2)and we get 100 which is 4.

Hareram said:   1 decade ago
Please explain it detail how. ?

Badri said:   1 decade ago
Please explain the above expression (such as 16>>>2).

Sneha said:   1 decade ago
I also wanna know the same thing..


Post your comments here:

Your comments will be displayed after verification.