Question discussion

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

314232Medium 2 replies 9,554 views
38
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); }}
  • A2
  • B129
  • C-127
  • DCompiler error
  • ENone of these
Correct answer: C
0
CCommunity
-127

Range of byte data in java is -128 to 127. But byte data type in java is cyclic in nature.
0
CCommunity
snippet.class Demo{ public static void main(String args)

{

byte a = 127;

++a;

System.out.println(a); }}