Answer 5 G. None of the above. All byte and short types are promoted to type int before being shifted. When the byte value of 32 is promoted to an int and shifted two bits to the left, the resulting value is 128. However, when it is cast back to a byte and stored in the variable named y , significant data is lost in the process, and the nonsense value of -128 is produced. Each time an integer value is shifted one bit to the right, its value is divided by two.
Any fractional part resulting from the division is lost.
Each time an integer value is shifted one bit to the left, its value is multiplied by a factor of two, provided that no data is lost in the process. Therefore, a two-bit left shift multiplies the operand by a factor of 4, provided no data is lost in the process. In this case, no data was lost, and the value assigned to y was equal to the value stored in x multiplied by four, giving a result of 20. All byte and short types are promoted to type int before being shifted. The result of the shift is type int .