Тесты
Язык сайта: Русский
Українська
English
Русский
Тесты по программированию
Вход
Регистрация
Тесты по программированию
Теория
сниппеты
Статьи
Главная
Android
Цены
FAQ
История Cosmo
Правила и условия сервиса
Политика конфиденциальности
Политика в отношении файлов cookie
Обратная Связь
hashmap
:
Язык контента: English
Русский
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?
hashmap
What will be the result of the following code execution? import java.util.*; class Employee { private String name; public Employee(String name) { this.name = name; } public String toString() { return name; } public boolean equals(Object obj) { HashCodeTest.count++; if (obj == null) return false; if (obj.getClass() != getClass()) return false; Employee emp = (Employee) obj; if (this.name == emp.name) { return true; } return false; } public int hashCode(){ return name.hashCode(); } } public class HashCodeTest { static int count = 0; public static void main(String[] args) { Map employees = new HashMap(); employees.put(new Employee("Joe"), new Integer("1")); employees.put(new Employee("Chandler"), new Integer("2")); employees.put(new Employee("Chandler"), new Integer("2")); employees.put(new Employee("Ross"), new Integer("3")); Iterator iterator = employees.keySet().iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } System.out.println(count); } } P.S. For experts - hashtags of the lines "Joe", "Chandler" and "Ross" are different.
hashmap
From which data structure will the "garbage collector" remove all items in which last reference to the key in this structure has disappeared?
hashmap
← Предыдущая
1
Следующая →
Зарегистрируйся сейчас
или
Подпишись на будущие тесты