What result will give the following code?

public class A {
    public int i = 0;

    public A() {
        i = 10;
    }

    public static void main(String[] args) {
        int i = 9;
        A a = new A();
        while(a.i < 10) a.doIt(); //9
    }

    public static void doIt() {
        i++;                             //12
        System.out.println("Hello");
    }
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback