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";
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

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes