What will be printed if you compile and run the following code:

public class Quizful {
    public static void main(String[] args) {
        byte b = 127;
        b += 129;
        System.out.println(b);
    }
}
Explanation
Byte type range is: from -128 to 127, where 127 + 1 = -128.
There is no compilation error for += operation, while there would be a compile error for b = b + 129 as result of + would be 256 with int type.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты