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

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
Зарегистрируйся сейчас
или Подпишись на будущие тесты