Тесты
Язык сайта: Русский
Українська
English
Русский
Тесты по программированию
Вход
Регистрация
Тесты по программированию
Теория
сниппеты
Статьи
Главная
Android
Цены
FAQ
История Cosmo
Правила и условия сервиса
Политика конфиденциальности
Политика в отношении файлов cookie
Обратная Связь
varargs
:
Язык контента: English
Русский
What will be printed out as a result of the following code execution / compilation? public class Test { static void m(int ... a) { System.out.println("1"); } static void m(Integer ... a) { System.out.println("2"); } public static void main(String[] args) { m(1, 2); } }
varargs
Which of the following methods are declared correctly?
varargs
What will be the result of the following code execution? class Alien { String invade(short ships) { return "a few"; } String invade(short... ships) { return "many"; } } public class Defender { public static void main(String [] args) { System.out.println(new Alien().invade(7)); } }
varargs
What is the result of the following code compilation and execution? public class MainClass { public static void test(int ...a) { System.out.println("int..."); } public static void test(Integer ...a) { System.out.println("Integer..."); } public static void test(Number ...a) { System.out.println("Number..."); } public static void main(String args[]){ Number n = new Integer(1); test(n.intValue()); } }
varargs
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"); } }
varargs
What will be displayed by the following code? public class test { public static void main(int[] args){ System.out.println("Hi, World!"); } public static void main(String... args){ System.out.println("Hello, World!"); } }
varargs
What will be the result of compilation and execution of the following code using JDK7 or newer? public class Main { public static void var(Integer x, int y) { System.out.println("Integer int"); } public static void var(Object... x) { System.out.println("Object"); } public static void var(int... x) { System.out.println("int... x"); } public static void var(Integer... x) { System.out.println("Integer..."); } public static void main(String... args) { byte i = 0; Integer i2 = 127; var(i, i2); } }
varargs
What will be the result of compiling and running the following code? public class Main { public static void var(int... x) //1 { System.out.println("int... x"); } public static void var(Object... x) //2 { System.out.println("Object... x"); } public static void var(Integer... x) //3 { System.out.println("Integer..."); } public static void main(String... args) { int i = 0; Integer i2 = 127; var(i, i2); } }
varargs
What will be the output of the following program: public class VarTest { public static void main(String[] X) { Integer x = 1; Integer y = 2; print(1); print(1,2); print(x); print(x,y); } static void print(int i) { System.out.print(1); } static void print(Integer... i) { System.out.print(2); } static void print(Integer i) { System.out.print(3); } static void print(int... i) { System.out.print(4); } }
varargs
← Предыдущая
1
Следующая →
Зарегистрируйся сейчас
или
Подпишись на будущие тесты