What is the result of the following code execution?

public class Main {

    static class X {
        static String x = Y.y;
    }

    static class Y {
        static String y = X.x;
    }

    public static void main(String[] args) {
        Y.y = "0";
        System.out.println(X.x);
    }
}
Explanation
1) Y.y is firstly initialized with null
2) X.x is initialized with a Y.y value (i.e. with null value)
3) Y.y is initialized with a X.x value (i.e. with null value)
4) After Y.y = "0" value of X.x remains null
So null is the result

Следи за CodeGalaxy

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

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