Lecture 7 Flashcards

1
Q

What are containers (In java)?

A

Containers are groups of data, much like arrays.

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

What is the difference between arrays and containers?

A

Containers have a flexible size, arrays do not.

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

What are the biggest pros and cons of containers compared to arrays?

A

pro: more flexible
con: less efficient

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

What is the order of an algorithm?

A

The order of an algorithm is a measure of the algorithm’s execution time. Determined by the order of the number of steps it takes, e.g. O(1), O(n), O(n^2).

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

What differentiates a set from a list?

A

In a set, there is no specific order and there cannot be duplicate elements. In a list, there is a specific order and there can be duplicate elements.

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

What happens if you add 23 to an ArrayList, how is this called and why?

A

It will be stored but as an object of the class Integer. This is called auto-boxing and the reason for this is that an ArrayList can only contain elements that are of a reference data type.

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

How can you specify the class of objects in an ArrayList?

A

ArrayList someArray = new ArrayList(); AND BRACKETY THINGIES! <>

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