Partitions map into segments and lock them individually instead of locking the whole map.ġ2) What is PriorityQueue in Java? ( answer)Ī data structure that always keeps the highest or lowest element at the head so that you can access or remove it in constant time.ġ3) What is type-erasure in Generics? ( answer) Hint - HashMap is fast but not threadsafe, Hashtable is slow but thread-safeġ0) What is the difference between synchronized and concurrent Collection in Java? ( answer)ġ1) How ConcurrentHashMap works in Java? ( answer) Hint - Yes, but only if you are reading from the HashMap and its initialized by a single thread, otherwise no.ĩ) What is the difference between HashMap and Hashtable in Java? ( answer) HashSet is actually backed by HashMap where keys are elements you store in HashSet and values are always null.ħ) Which two methods you should override for an Object to be used as a key in hash-based Collections? ( answer)Ĩ) Can you use HashMap in a concurrent application? ( answer) Hint - same like HashMap, using hashing and equals() and hashCode() method. Hint - TreeSet is one example of a sorted Collection Hint - use set when you don't need duplicates, use List when you need order with duplicates, and use Map when you need to store key-value pair.ĥ) Which Sorted Collection have you used? ( answer) Hint: Collection, List, Set, Map, ArrayList, Vector, LinkedList, HashMap, etcĤ) When do you use Set, List, and Map in Java? ( answer) Hint: Java feature to ensure type safety at compile time.ģ) Which are your favorites classes from the Java Collection Framework? ( answer)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |