What is the result of the following code execution?

public class Test {
    static { i = 5; }
    static int i = 6;

    public static void main(String[] args) {
        System.out.println(i);
    }
}
Explanation
Static initialization blocks and initialization of static variables are performed in the same order in which they are indicated in the class. Therefore, i = 5 command will be executed first and i = 6 after.

very good quesiton

2017 Jun 16, 12:01:15 PM

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести