Тести
Мова сайту: Українська
Українська
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
Наступна →
Зареєструйся Зараз
або
Підпишись на майбутні тести