Quiz8-Arrays Flashcards

1
Q

Subscripts are used to identify specific elements in an array.(T/F)

A

True

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

Unlike variables, arrays need to be initialized separately from the declaration. (T/F)

A

False

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

Array bounds checking happens at runtime. (T/F)

A

True

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

The first step when calculating the average of all values in an array is to get the sum of all the values. (T/F)

A

True

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

If an array, names, consists of a list of usernames, then names[1] holds the value of the first username in the list. (T/F)

A

False

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

Each element in a two-dimensional array has two subscripts. (T/F)

A

True

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

To calculate the total of the values in an array. a loop is used with an accumulator variable. (T/F)

A

True

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

An array, like a variable, can hold only one value. (T/F)

A

False

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

It is usually much easier to process a large number of items in an array than to process a large number of items that are stored in separate variables. (T/F)

A

True

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

The number of elements in an array is the value of the subscript of the last element in that array. (T/F)

A

False

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

One drawback to the sequential search is that it cannot be used with an array that contains string elements. (T/F)

A

False

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

The term “parallel array” is a synonym for a two-dimensional array. (T/F)

A

False

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

An individual element in an array is identified by its ____________.

A

subscript

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

A type of loop that exists in some programming languages specifically for stepping through an array and retreiving the value of each element is known as a ___________ loop.

A) Step
B) For Each
C) While Each

A

B) For Each

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

____________ arrays are two or more arrays that hold related date where each element of one array has the same subscript as a corresponding element in the other arrays.

A

parallel arrays

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

Two-dimensional arrays can be thought of as containing ___________.

A

rows and columns

17
Q

Every element in an array is assigned a unique number known as a(n) ______________.

18
Q

What is the term used for the number inside the brackets of an array that specifies how many values the array can hold?

A

size declarator

19
Q

When working with arrays, most programming languages perform ______________ to ensure that programs don’t use invalid subscripts.

A

array bounds checking

20
Q

What type of error occurs when a loop through an array iterates one time too few or one time too many?

A) runtime error
B) off-by-one error
C) validation error

A

B) off-by-one error

21
Q

How many subscripts do you need to access one element in a two-dimensional array?

22
Q

In the following declaration, what is the data type of the elements in the array?

Declare Integer numbers[SIZE]

23
Q

Which of the following statements is true about this array declaration??

Declare Integer numbers[5] = 123,456,789,321,654

A) This is an error; there should be 6 integers in the array
B) This is an array declaration and initialization
C) None of these statements are true

A

B) This is an array declaration and initialization

24
Q

Given the following statement, what is the subscript for the data value 92?

Declare Integer numbers[5] = 83,92,78,94,61

A

1 is the subscript

25
Which of the following array declarations would be best suited for storing prices of items sold in a store? A) Declare Integer itemPrice[SIZE] B) Declare Real itemPrice[SIZE] C) Declare String itemPrice[SIZE]
B) Declare Real itemPrice[SIZE]
26
What would display if following statements are coded and executed? Declare Integer scores[3]= 76,94,83 Declare String names[3]= "Joe","Amy","Pat" Display names[1] Display "Your test score is: " Display scores[2] A) Joe Your test score is: 94 B) Amy your test score is: 94 C) Amy your test score is: 83
C) Amy your test score is: 83
27
Which is the correct way to pass an array named studentScores that holds 25 values to a function named getAverage and save the result to a variable named average? A) Set average=getAverage (studentScores, 25) B) Set getAverage = average(studentScores[25]) C) Set average = getAverage(studentScores)
A) Set average = getAverage(studentScores,25)
28
Given the following array declaration, what value is stored in testScores[2][0] Declare Integer testScores[3][3]= 66, 77, 88 98, 87, 76 65, 74, 89
65