COP2253 Zybooks Chapter Five Flashcards

1
Q

array

A

a special variable having one name, but storing a list of data items, with each item being directly accessible

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

element

A

used to refer to each item in an array

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

What statement declares a reference variable and allocates an array?

A

dataType[] arrayName = new dataType[numElements]

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

common for loop structure for iterating through an array

A
for (i = 0; i < myArray.length; ++i) {
   // Loop body accessing myArray[i]
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

temporary variable

A

a variable used briefly to store a value (useful for swapping)

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

enhanced for loop (or for each loop)

A

for loop that iterates through each element in an array

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

loop variable

A

a variable whose scope is limited to the loop

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

perfect size array

A

an array where the number of elements is exactly equal to the memory allocated

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

oversize array

A

an array where the number of elements used is less than or equal to the memory allocated

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

oversize array declaration

A

int[] myArray = new int[1000];

int myArraySize = 0;

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

oversize arrays typically use three variables:

A

the array reference, the current size, and a constant for the array capacity

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

a method that expects a perfect size array as an argument will have:

A

one parameter for the array reference, but no parameter for the array size

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

a method that expects an oversize array will have:

A

two parameters to pass the array, one for the array reference and one for the array size

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

a method can return at most:

A

one item

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

side effect

A

an error that unintentionally modifies data

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

how many tasks should a method perform?

A

one