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
Зареєструйся Зараз
або Підпишись на майбутні тести