Welcome Guest | Sign in | Register
Variables and Loops - Discussion Page For Q.2984 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Variables and Loops > Questions and Answers

Q: What is the output for the below code ?

1. public class Test {
2. public static void main(String[] args){
3. byte i = 128;
4. System.out.println(i);
5. }
6. }
A. 128 B. 0
C. Compilation fails with an error at line 3 D. Compilation fails with an error at line 4

Answer and Explanation

Answer:Compilation fails with an error at line 3

Explanation:
byte can only hold up to 127. So compiler complain about possible loss of precision.

Comment on this Question

Name:

Loading...




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