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
True or false: in C# the length of an array cannot be changed. After it is instantiated with a length, dynamic resizing is not an option.
True
True or false: for an array that is dimensioned with a Length of 100, valid subscripts are 0-100
False
True or false:
Double [ ] price = new double [ ] { 3, 2.2, 4.7, 6.1, 4}
Looking above the value of price.Length is 5
True
True or false:
Double [ ] price = new double [ ] { 3, 2.2, 4.7, 6.1, 4}
With the declaration above, price[2] refers to 2.2
False
True or false:
Double [ ] price = new double [ ] { 3, 2.2, 4.7, 6.1, 4}
With the declaration above, price[5] generates a runtime error
True
True or false: the type used in the foreach expression must match the array type
True
True or false: when you pass an array to a method, by default, a copy of each element in the array is made and passed to the method
False
True or false: a parallel array is used to create string arrays because multiple characters are included within each element
False
True or false: arrays can be sent to methods as arguments, and methods can have arrays as their return type
True