What is the output of the given java code? byte x = 64, y;
What is the output of the given java code?
byte x = 64, y;
y = (byte) (x << 4);
system.out.println(y);
Show answerHide answer
Correct answer: (A) 0
Explanation
x << 4 is 64 × 16 = 1024 = 0x400 (as int). Casting to byte keeps only the low 8 bits, 0x00, so y prints 0.