Welcome Guest | Sign in | Register
Operators and Assignments - Discussion Page For Q.2926 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Operators and Assignments > Questions and Answers

Exercise:

Section 1

Q: 4. Which two statements are equivalent?
1. 3/2
2. 3<2
3. 3*4
4. 3<<2
A. 1 and 2 B. 2 and 3
C. 3 and 4 D. 1 and 4

Answer and Explanation

Answer:3 and 4

Explanation:
(1) is wrong. 3/2 = 1 (integer arithmetic).
(2) is wrong. 3 < 2 = false.
(3) is correct. 3 * 4 = 12.
(4) is correct. 3 <<2= 12. In binary 3 is 11, now shift the bits two places to the left and we get 1100 which is 12 in binary (3*2*2).

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.