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 2 of 3.
Kumari.N said:
1 decade ago
3/2 = 1 (Integer arthimetic).
3<2 = false.
3*4 = 12.
3<<2 = 12 In binary 3 is 11 and left shift 11 to two places that is 1100.
Which is equal to 12.
3<2 = false.
3*4 = 12.
3<<2 = 12 In binary 3 is 11 and left shift 11 to two places that is 1100.
Which is equal to 12.
Priyanka Srivastava said:
9 years ago
Sir, please give the explanation about how 16 >>> 2 is equals 16 >> 2.
I do not understand the question.
I do not understand the question.
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.
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.
Eod said:
1 decade ago
@Venkat, '^' operation is not Math.Exp, as @Utpal said before it's bit wise OR operation.
Venkat said:
1 decade ago
Guys can you please explain about third option "(3) is wrong, 16/2^2 = 10" how?
Isaac said:
1 decade ago
Which of these statements are equivalent 3/2, 3<2, 3*4, 3<<2.
D.Sapna said:
1 decade ago
What is the difference between 16>>2 and 16>>>2?
Badri said:
1 decade ago
Please explain the above expression (such as 16>>>2).
BIKASH DEY said:
1 decade ago
Can any one tell me mathematically how is 16/2 ^ 2 = 10.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers