Vidyalelo
Java Programming · Q56

Data Types and Variables

Programming · Java Programming · question 56

Q56

What will be output of following program? public class Test public static void main(String[] args) byte b=127; b++; b++; System.out.println(b);

A.
2
B.
129
C.
-127
Answer
D.
Compiler error
E.
None of these

Answer: Option C

Solution

Answer: Option C
Solution:

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