What is the result of the following code compilation and execution?

public class Clazz {
    private void process(String... s) {
        System.out.print("*");
    }
    private void process(String s) {
        System.out.print("1");
    }
    private void process(String s, String a) {
        System.out.print("2");
    }
    public static void main(String[] args) {
        Clazz c = new Clazz();
        c.process("asd");
        c.process("asd","asd");
        c.process("asd","asd","asd");
    }
}
Explanation
Methods with vararg-parameters are analysed in the last order by compiler - only if all other methods are not suitable. Process("asd") and process("asd", "asd") will be compiled without errors.

Следи за CodeGalaxy

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

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