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.

Следи за CodeGalaxy

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

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