What will be printed as a result of compiling and running the following code?

public class Test {
    private static Boolean b1, b2;
    
    public static void main (String[] args) {
        if (b1 || !b2 || !b1 || b2) {
            System.out.println(true);
        }
        else {
            System.out.println(false);
        }
    }
}
Explanation
When using wrapper objects in operations designed for primitives, the methods that return a primitive value are called. In this case booleanValue(). This will cause throwing of NullPointerException.

Следи за CodeGalaxy

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

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