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?
- 16*4
- 16>>2
- 16/2^2
- 16>>>2
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.
Jose Marti said:
1 decade ago
Because the unsigned right shift operator ">>>" shifts a ZERO into the leftmost position.
In binary 16 is 10000, now shift the bits two places to the right. We get 100. Then add a 0 into the leftmost position, we get 0100 which is 4.
In binary 16 is 10000, now shift the bits two places to the right. We get 100. Then add a 0 into the leftmost position, we get 0100 which is 4.
(2)
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?
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..
Naveen said:
1 decade ago
Is correct. 16 >>> 2 = 4.
How it will come will you please provide mathamatically discription.
How it will come will you please provide mathamatically discription.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers