What will be indicated at the console as a result of the code:

public class B {
    public static void main(String[] args) {
        byte b = 127;
        byte result = (byte)(b + 1);
        System.out.println(result);
    }
}
Explanation
Variables of the byte type occupy 8 bits, 127 coded as 01111111 (0 - sign bit) after adding 1 we obtain the number encoded as 10000000 - which corresponds to -128

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести