What will be the result of compiling and running the following code:

public class Test {
    private static String name = "Duke";

    public static void main(String[] args) {
        System.out.println("Hello ");

    private static Test getTest(){
        return null;
Variable name is static, therefore call via method will be replaced with class during the compilation: Test.name. So, no error will occur, and 'Hello Duke' will be printed out.

Следи за CodeGalaxy

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

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