Multiple choice technology programming languages

What will be the output of the below code snippet? public class Quiz10 { public static void main(String args[]) { System.out.println((int) (char) (byte) -1); } }

  1. 65536

  2. 65535

  3. 1

  4. -1

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The byte -1 has all bits set (11111111 in two's complement). When cast to char, sign extension produces 0xFFFF (16 bits all 1), which represents 65535 in unsigned char. Cast to int preserves this value as 65535. This demonstrates sign extension behavior during primitive widening conversions.