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

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

Q: What will be output of following program?

public class Datatype {
public static void main(String[] args) {
byte b=127;
b++;
b++;
System.out.println(b);
}
}
A. 129 B. 2
C. -127 D. Compiler error

Answer and Explanation

Answer:-127

Explanation:
Range of byte data in java is -128 to 127. But byte data type in java is cyclic in nature.

Comment on this Question

Name:

Loading...




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