Java Collections Framework Flashcards

1
Q

What are the 2 interfaces in the Java Collections Framework?

A

Map
Collection

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

What is the benefit of collections being generic?

A

Polymorphism.
Bugs caught at compile time.

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

What are the 4 structures in that inherit Collection?

A

Set, List, Queue, Dequeue

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

Define each of the 3 set implementations…

A

HashSet : No order; fastest.
TreeSet : Order based on value; Slower than hash set.
LinkedHashSet : Order based on input.

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

Are List structures ordered?

A

Yes.

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

What are the 2 concrete implementations of List?

A

ArrayList
LinkedList

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

Define the Queue structure…

A

A collection of data stored for processing. FIFO processing.

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

What are the 4 main methods for Queue?

A

add : Adds element to queue if possible, throws exception if not.
offer : Adds element to queue if possible. Returns false if not.
remote : Removes and returns the head of the queue, throws NoSuchElementException if not.
poll : Remove and returns head of queue, returns null if not.

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

Define a Dequeue…

A

A double ended queue that can be inserted and deleted from either end.

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

What are the 3 types of operation on Dequeue?

A

Insert, Remove, Examin.

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

Define the Map interface…

A

No a direct collection, rather a collection of references that map to values.

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

Define the 3 types of map…

A

HashMap : Fastest, order irrelevant.
TreeMap : Order guaranteed based on value.
LinkedHashMap : Order based on order of insertion.

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