Тесты
Язык сайта: Русский
Українська
English
Русский
Тесты по программированию
Вход
Регистрация
Тесты по программированию
Теория
сниппеты
Статьи
Главная
Android
Цены
FAQ
История Cosmo
Правила и условия сервиса
Политика конфиденциальности
Политика в отношении файлов cookie
Обратная Связь
maps
:
Язык контента: English
Русский
Java Collections
maps
Which data structure that implements a Map interface uses an == operator, rather than the equals method for objects comparison?
maps
What will be printed after the following code execution? import java.util.*; public class MapTest { public static void main( String[] args ) { Map<String, Integer> map1 = new HashMap<String, Integer>(); Map<String, Integer> map2 = new HashMap<String, Integer>(); map1.put( "Number1", new Integer( 100 ) ); map1.put( "Number2", new Integer( 200 ) ); map1.put( "Number3", new Integer( 300 ) ); List<Map> list = new ArrayList<Map>(); list.add( map1 ); list.add( map2 ); HashMap resultMap = (HashMap) list.get( 0 ); System.out.println( "Number: " + resultMap.get( "Number2" ) ); } }
maps
What interfaces provide the ability to store objects as a "key-value" pairs?
maps
What will be displayed with the following code? import java.util.EnumMap; import java.util.Map; enum Types { A, B, C } public class Test { static Integer value; public static void main(String args[]) { Map<Types, Integer> m = new EnumMap<Types, Integer>(Types.class); m.put(Types.A, value); System.out.println(m); } }
maps
Consider the following code: import java.util.*; class MyDataStore { public static void main(String [] args) { // Put the code structure.put("a", 420); System.out.println(structure.get("a")); } } Which from the mentioned options can be inserted into the line 4 (independently) for class to successfully compile and run?
maps
Select the line which should be inserted in the comparator body below, so that the treeMap keys will be sorted in ascending order (COM1 COM2 COM8 etc). public class Main { public static void main(String[] args) { Comparator<String> comparator = new Comparator<String>() { @Override public int compare(String string_1, String string_2) { //insert code here } }; TreeMap<String, String> treeMap = new TreeMap<String, String>(comparator); treeMap.put("COM1", "\\Device\\Serial0"); treeMap.put("COM2", "\\Device\\Serial1"); treeMap.put("COM8", "\\Device\\Nmserial0"); treeMap.put("COM9", "\\Device\\Nmserial1"); treeMap.put("COM10", "\\Device\\Nmserial2"); treeMap.put("COM11", "\\Device\\Nmserial3"); } }
maps
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); }
maps
Look at the following source code: 1. import java.util.*; 2. 3. class SomeClass { 4. public static void main(String... args) { 5. TreeMap<String, Integer> myMap = new TreeMap<String, Integer>(); 6. myMap.put("d", 1); 7. myMap.put("b", 2); 8. myMap.put("e", 3); 9. myMap.put("c", 4); 10. // space for inserting code 11. System.out.println(myMap2.get("b") + " " + myMap2.get("d")); 12. } 13. } Which lines of code, placed independently in line 10 will result in printing "2 1" (without quotes)? (choose 2 options)
maps
What will be the result of compilation and execution of the following code: 1. import java.util.*; 2. 3. class SomeClass { 4. public static void main(String[] args) { 5. TreeMap<String, Integer> myMap = new TreeMap<String, Integer>(); 6. myMap.put("a", 50); myMap.put("b", 60); 7. myMap.put("c", 70); 8. NavigableMap<String, Integer> myMap2 = myMap.headMap("d", true); 9. myMap.put("e", 90); 10. myMap2.put("f", 100); 11. System.out.println(myMap.size() + " " + myMap2.size()); 12. } 13. }
maps
← Предыдущая
1
2
Следующая →
Зарегистрируйся сейчас
или
Подпишись на будущие тесты