ProgrammingVery hardWipro Elite · TCS NQT Prime

What is printed?

What is printed?
byte b = 10;
b += 120;
System.out.print(b + " " + (b >>> 1));
  1. A. 130 65
  2. B. -126 -63
  3. C. -126 126
  4. D. -126 2147483585

Correct answer: D. -126 2147483585

b += 120 casts 130 back to byte, giving -126; b >>> 1 promotes to int 0xFFFFFF82, and the unsigned shift gives 0x7FFFFFC1 = 2147483585.

More OOP with C++ and Java questions

Exams that ask this topic