Collections Flashcards

1
Q

Packages

A

Packages organize Java classes and create scope to prevent two classes with the same name from having a name collision.

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

Fully qualified Class name

A

Is the package name along with the class name.

java. util.Scanner in = new 
    java. util.Scanner(System.in);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Collections

A

Are classes in java.util package that define data structures that make working with a set of data easier.
Collections are written to be generic so that they are useful for all reference types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
List
List variableName = new ArrayList();
A

Is an interface, unlike a class contains no code and just creates a data type with guaranteed functionality.

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

Boxing

A

Boxing is moving a primitive value from the Stack to a Wrapper Class object on the Heap.
Primitive → Wrapper Class

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

Unboxing

A

Unboxing is moving the value from a Wrapper Class on the Heap to an appropriate primitive value on the Stack.
Wrapper Class → Primitive type

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

Stack

A

A data structure that organizes data Last In First Out (LIFO). Optimizes Insertion and Deletion, but not possible to search.

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

For each Loop characteristics

A
  1. Loops through each item in a collection or array in order.
  2. Cannot modify the collection or array in the loop
  3. Does not know the iteration.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Queue

A

A data structure that organizes data First in First Out (FIFO). Optimizes Insertion and Deletion, but not possible to search.

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

List characteristics

A
  1. Maintains the Order of Insertion.
  2. Elements can be accessed by index.
  3. Allows duplicate elements.
  4. Can hold only one data type that is defined by reference type.
  5. Can grow and shrink as items are added and removed.
  6. An ordered set of elements that is 0-indexed like an array.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Stack methods

A

push( x ) - insert at the beginning of the Stack.
pop() - remove items from the beginning of the Stack.
peek() - to look at the next item without removing it.
isEmpty() - used to determine if the Queue has remaining items.

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

Queue methods

A

offer( x ) - insert at the end of the Queue
poll() - remove items from the beginning of the Queue
peek() - used to look at the next item without removing it
isEmpty() - used to determine if the Queue has remaining items

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

List variableName = new ArrayList();

A

Sets the Reference Data Type that the list will hold.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
ArrayList
List variableName = new ArrayList();
A

Is a class that implements the List data type, and will be instantiated by the new keyword.

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

List methods

A

size(), add( x ), add( index, x), get( index ), remove( index )

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