What is the result of the following program:

class Main {
    public static void main(String[] args) {
        long[] array2 = {3, 4};
        for (int x : array2) { 
            System.out.println(x);
        }
    }
}
Explanation
The type of the loop variable must be compatible by assignment with the type of the array elements.
Code will compile if you change the type of elements in the array to int or if you change the type of a loop variable to long.

Следи за CodeGalaxy

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

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