Test 1 Flashcards

1
Q

What is this for loop doing:
int[ ] num = {2, 4, 6, 7, 9, 10, 15, 21, 34};
int i;
for (i = 0; i

A

Setting each number of the array to the index number

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

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

A

9

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

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

A

Error because no num [10]

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

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

A

Changes num[2] to 7

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

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

A

Changes num[4] to 10

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

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.

A

True

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

True or false: given the for statements form, for (initialization; test; update), the initialization is perforated with each iteration through the loop.

A

False

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

True or false: the for statement may not be written without an initialization component.

A

False

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

True or false: the loop control variable used with a for statement must be an integral value

A

False

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

True or false: the loop body is always executed at least one time with both the pretest and the posttest loop

A

False

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

True or false: the do… While is used to implement a posttest loop

A

True

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

Given the following what would be the output?

For (int cnt = 0; cnt

A

012

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

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

A

9

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

True or false: you can declare an array without dimensioning its size, but the size must be determined before you can access it

A

True

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

True or false: array identifiers are normally defined using a plural noun

A

False

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

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.

17
Q

True or false: for an array that is dimensioned with a Length of 100, valid subscripts are 0-100

18
Q

True or false:
Double [ ] price = new double [ ] { 3, 2.2, 4.7, 6.1, 4}
Looking above the value of price.Length is 5

19
Q

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

20
Q

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

21
Q

True or false: the type used in the foreach expression must match the array type

22
Q

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

23
Q

True or false: a parallel array is used to create string arrays because multiple characters are included within each element

24
Q

True or false: arrays can be sent to methods as arguments, and methods can have arrays as their return type

25
True or false: when you use the assignment operator with an array, individual copied to another memory location
False
26
True or false: with parallel arrays, the relationship is established through using the same subscript or index to refer to the element in both arrays
True
27
Data members should be defined with an access mode of ________
Private
28
Constructors are used to ________ a class
Instantiate
29
Fields or data members are also called ________
Instance variables
30
After a project has been created and a new class added to your application, you can use the ________ window in visual studio to create a class diagram
Solution explorer
31
``` Array.Copy(waterDepth, 2, w, 0, 5); The Copy( ) method, shown above, is a(n) ________ method ```
Class
32
An entire array collection of data can be ordered alphabetically with a call to the Array class member method ________
Sort
33
To create an array to hold the 5 numeric scores, you could write ________
Int[ ] score = new int[5];
34
Elements in array are sometimes referred to as ________ variables
Indexed