What will be the result of the following program execution?

public class Program {
    public static void main(String[] args) {
        int N = 5;
        int m[] = new int[N];
    label:    
        for (int i = 0; i < N; ++i) {
            m[i] = i * i;
            if (m[i] == 9) {
                System.out.print("9 ");
                goto label;
            }
        }
    }
}
Explanation
Java does not have a goto statement. Instead goto is just a reserved word to force programmers not to use it as a variable name. For successful compilation goto can be replaced with break statement.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback