What will be printed out to console as a result of the following code execution?

public class Clazz {
    public static void main(String[] args) {
        int a = 0;
        System.out.println("a=" + new Integer(a = 1));
    }
}
Explanation
a = 0 initially. The assignment operator "=" has the following form, speaking abstractly,
int operator_= (int n){ return n; }
Therefore, (a = 1) returns 1, which is passed to the constructor of the Integer class

Следи за CodeGalaxy

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

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