Что можно сказать о следующей программе?

public class String {
    static String[][]String = {{"String"}};       // 1

    static {
        System.out.println(String.class);         // 2
    }

    public static void main(String[] args) {      // 3
        System.out.println(String.class);         // 4
    }
}
Explanation
In this code declaration of class String hides java.lang.String class. So String refers to defined class and no longer to java.lang.String class. Because of this an error will occur in line 1 -java.lang.String type is cannot be cast to the String type

Слідкуй за CodeGalaxy

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

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