Test 1 Flashcards
What is this for loop doing:
int[ ] num = {2, 4, 6, 7, 9, 10, 15, 21, 34};
int i;
for (i = 0; i
Setting each number of the array to the index number
What value will be in the variable i when the loop body is complete? int[ ] num = {2, 4, 6, 7, 9, 10, 15, 21, 34};
int i;
for (i = 0; i
9
Without doing the loop, but just using the initial values what does num[5] = 10; do?
int[ ] num = {2, 4, 6, 7, 9, 10, 15, 21, 34};
int i;
for (i = 0; i
Error because no num [10]
Without doing the loop but just using the initial values, what does num[2]++ do?
int[ ] num = {2, 4, 6, 7, 9, 10, 15, 21, 34};
int i;
for (i = 0; i
Changes num[2] to 7
Without doing the loop but using the initial values, what does num[2+2]++ do?
int[ ] num = {2, 4, 6, 7, 9, 10, 15, 21, 34};
int i;
for (i = 0; i
Changes num[4] to 10
True or false: in order to have more than one statement be executed as part of the loop body, the statements must be enclosed in curly braces.
True
True or false: given the for statements form, for (initialization; test; update), the initialization is perforated with each iteration through the loop.
False
True or false: the for statement may not be written without an initialization component.
False
True or false: the loop control variable used with a for statement must be an integral value
False
True or false: the loop body is always executed at least one time with both the pretest and the posttest loop
False
True or false: the do… While is used to implement a posttest loop
True
Given the following what would be the output?
For (int cnt = 0; cnt
012
What value is associated with num.Length if:
int[ ] num = {2, 4, 6, 7, 9, 10, 15, 21, 34};
int i;
for (i = 0; i
9
True or false: you can declare an array without dimensioning its size, but the size must be determined before you can access it
True
True or false: array identifiers are normally defined using a plural noun
False