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

public class Test {
    public static void main(String... args) {
        test("A", "B");
    }

    public static void test(String... str) {
        System.out.print("A");
    }

    public static void test(String str1, String str2) {
        System.out.print("B");
    }

    public static void test(String str1, String... str2) {
        System.out.print("C");
    }
}
Explanation
Each of the three test() methods is potentially applicable for the call test("A", "B").
Because among them there is only one method with a fixed number of arguments, it is he who will be called.

Следи за CodeGalaxy

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

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