Collections Flashcards

1
Q

General collection interfaces

A

(Collection, Set, Map, List, Queue, SortedSet, SortedMap)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Interfaces extending Collection. Is Map part of Collection interface?

A

List, Set, Queue
Map is not collection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

TreeSet vs TreeMap

A

TreeMap allows duplicate values, TreeSet - no
TreeMap is sorted based on keys while TreeSet is sorted based on objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

HashMap vs Hashtable

A

Hashtable is synchronized, whereas HashMap is not.
Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Requirements for implementation of hashCode to achieve best performance

A

uniform distribution
alwasy return the same value for same object
same value for equal objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Differences between Hashtable and ConcurrentHashMap

A

ConcurrentHashMap uses multiple locks
Hashtable uses single lock

ConcurrentHashMap locking is applied only for updates. In case of retrievals, it allows full concurrency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

EnumSet, EnumMap

A

EnumSet, EnumMap - their elements/keys come from a single enum type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

WeakHaskMap

A

the keys of the map are stored in a weakreference
key-value pairs can dynamically be dropped from the map when the only reference to the key is from the weak reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

IdentityHashMap

A

using reference-equality in place of object-equality when comparing keys (and values)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Implementation details of about ConcurrentHashMap. Synchronization.

A

lock on buckets instead of whole map

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Iterator and modification of a List. ConcurentModificationException.

A

occurs when something we are iterating is changed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly