Collections Flashcards

1
Q

What does the Java API provide for data structures?

A

Predefined data structures called collections

Collections are used to store groups of related objects in memory.

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

What is the main purpose of the Collection interface?

A

Defines common operations for lists, vectors, stacks, queues, priority queues, and sets.

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

What are the two types of containers supported by the Java Collections Framework?

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

What type of elements do Sets store?

A

Nonduplicate elements.

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

How do Lists store elements?

A

In an ordered collection.

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

Describe how Stacks process objects.

A

In a last-in, first-out fashion.

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

Describe how Queues process objects.

A

In a first-in, first-out fashion.

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

How do PriorityQueues process objects?

A

In the order of their priorities.

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

What is the root interface for manipulating a collection of objects in Java?

A

Collection interface.

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

What is the significance of the placeholder ‘T’ in ArrayList<T>?</T>

A

It is a placeholder for the type of elements the ArrayList will hold.

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

What are generic classes in Java?

A

Classes that can be used with any type.

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

What does boxing refer to in Java?

A

Wrapping primitive values as objects.

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

What does unboxing refer to in Java?

A

Extracting primitive values from their corresponding object.

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

What does the Iterable interface provide?

A

A method to obtain an Iterator object to traverse elements.

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

What is the purpose of the Iterator interface?

A

Provides a uniform way for traversing elements in various types of collections.

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

What are the two concrete classes used to create a List?

A
  • ArrayList
  • LinkedList
17
Q

What is the diamond (<>) notation used for in Java?

A

To simplify the instantiation of generic class objects.

18
Q

How does a queue operate?

A

First-in, first-out data structure.

19
Q

What distinguishes a priority queue from a regular queue?

A

Elements are assigned priorities; highest priority is removed first.

20
Q

What is the relationship between Vector and Stack classes?

A

Stack is a subclass of Vector.