Тести
Мова сайту: Українська
Українська
English
Русский
Тести з програмування
Вхід
Реєстрація
Тести з програмування
Теорія
Сніпети
Статті
Головна
Android
Ціни
FAQ
Історія Cosmo
Правила та умови сервісу
Політика конфіденційності
Політика щодо файлів cookie
Зворотній Зв’язок
lists
:
Мова контенту: English
Русский
What will happen during the following code execution? import java.util.*; public class Test { public static void main(String[] args) { List a = new ArrayList<Double>();// 4 a.add("1.5");// 5 List<Double> b = new ArrayList();// 6 b.add("1.5");// 7 System.out.println(a + " " + b); } }
lists
What will be the result of the following code compilation and execution? import java.util.*; public class Test { public static void main(String[] args) { List buf = new ArrayList(2); System.out.print(buf.size()); buf.add(10); System.out.print(buf.size()); buf.add(20); buf.add(30); System.out.print(buf.size()); } }
lists
What will the given hashMap contain, after the below code is compiled and run? public static void main(String[] args) { HashMap hashMap = new HashMap(); List list = new ArrayList(); list.add(hashMap); hashMap.put(list, null); hashMap.put(list, null); }
lists
What will happen if you attempt to compile and run this code? import java.util.*; class A {} class B extends A {} class B1 extends A {} class B2 extends A {} class C1 extends B {} class C2 extends B {} public class AsListInt { public static void main(String[] args) { 1. List<A> list1 = Arrays.asList(new B(), new B1(), new B2()); 2. List<A> list2 = new ArrayList<A>(); 3. Collections.addAll(list2, new C1(), new C2()); 4. List<A> list3 = Arrays.asList(new C1(), new C2()); } }
lists
What can we see in the console after next code executes: import java.util.ArrayList; import java.util.Iterator; public class Quizful { protected static ArrayList<Integer> wallet; public Quizful() { wallet = new ArrayList<Integer>(); } public static int money() { int aSum = 0; Iterator<Integer> iterator = wallet.iterator(); // --1-- while (iterator.hasNext()) aSum += iterator.next(); return aSum; } public static int money2() { int aSum = 0; for (Integer I : wallet) // --2-- aSum += I.intValue(); return aSum; } public static void main(String[] args) { wallet.add(new Integer(5)); // --3-- System.out.println(money() + money2()); } }
lists
Which lines in the following code will cause a compilation error? 01: import java.util.*; 02: public class TestClass { 03: public static void main(String[] args) { 04: List<Number> list = new ArrayList<Integer>(); 05: list.add(1); 06: list.add(1.2); 07: list.add(new Integer()); 08: list.add(new Integer("5")); 09: } 10: }
lists
What happens if the following code is executed? import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; public class Test<T> implements Iterable<T>{ // 1 private List<T> list = new ArrayList<T>(); public void addList(T... ts) { Collections.addAll(list, ts); } public static void main(String... args) { Test<String> t = new Test<String>(); t.addList("Hello", "world", "!"); for (String str : t) { // 2 System.out.print(str + " "); } } public Iterator<T> iterator() { return new Iterator() { // 3 private int index = 0; public boolean hasNext() { return index < list.size(); } public Object next() { return list.get(index++); } public void remove() { throw new UnsupportedOperationException("unsupported operation"); } }; } }
lists
Which of the following options could be inserted into (1) without causing compilation error import java.util.*; public class Test { public static void main(String[] args) { List<?> lst = new ArrayList<String>(); // (1) Insert code here } }
lists
Choose the correct result of compiling and running the following code: import java.util.*; class Generics13 { public static void main(String[] args) { List<Integer> list = new LinkedList<Integer>(); list.add(1); list.add(4); list.add(-4); for(Iterator i = list.iterator(); i.hasNext();) { Integer in = i.next(); System.out.println(in); } } }
lists
What is the result of compilation and execution of the following code? public class Test { public static void main(String[] args) { List<Integer> list = new ArrayList<Integer>(); list.add(100); list.add(200); list.add(300); list.add(200); Set<Number> set = new HashSet<Integer>(list); System.out.println(set.size()); } }
lists
← Попередня
1
2
3
Наступна →
Зареєструйся Зараз
або
Підпишись на майбутні тести