EGR 1400 Exam 2

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:12 PM on 4/2/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

34 Terms

1
New cards

When the location of the original variable is passed as an argument from the calling method to the called method, we say that it is...

a. passed by reference

b. copy passed

c. passed by value

d. reference passed

e. none of the above

a. passed by reference

2
New cards

How many times does the message box get executed in a loop that begins with the following statement?

int I;

for (I = 1; I < 4; I++)

{

MessageBox.Show(I);

}

a. 0

b. 2

c. 3

d. 1

e. none of the above

c. 3

3
New cards

What is the value of the variable I after the loop is finished executing?

int I;

for (I = 1; I < 4; I++)

{

MessageBox.Show(I);

}

a. 1

b. 2

c. 3

d. 4

e. none of the above

d. 4

4
New cards

How many locations will there be for an array declared as: string[ ] Names = new string[4];

a. 4

b. 3

c. 2

d. 1

e. none of the above

a. 4

5
New cards

After the code is finished executing, what is the value of A[1]?

int[ ] A = new int[5];

int[ ] B = new int[3];

int x;

for (x = 0; x < 5; x++)

{

A[x] = x * 2 + 4;

}

a. 10

b. 8

c. 6

d. 0

e. none of the above

c. 6

6
New cards

What is the maximum index of the array, B?

int[ ] A = new int[5];

int[ ] B = new int[3];

int x;

for (x = 0; x < 5; x++)

{

A[x] = x * 2 + 4;

}

a. 0

b. 2

c. 3

d. 4

e. none of the above

b. 2

7
New cards

Which of the following statements will set RandNum to a value between 1 and 6 (including 1 and 6)?

a. RandNum = myRand.Next(0,6);

b. RandNum = myRand.Next(0,7);

c. RandNum = myRand.Next(1,7);

d. RandNum = myRand.Next(1,6);

e. RandNum = myRand.Next();

c. RandNum = myRand.Next(1,7);

8
New cards

How many times will the following sum execute?

int A=0;

do

{

A = A + 2; //this is the sum, count here

} While (A >= 0);

a. 0

b. 1

c. 2

d. 3

e. none of these, this is an infinite loop

e. none of these, this is an infinite loop

9
New cards

How many times will the following sum execute?

int X = 0

while (X <= 8)

{

X = X + 2; // this is the sum, count here

}

a. 6

b. 5

c. 4

d. 0

e. none of these, this is an infinite loop

b. 5

10
New cards

Which of the following pieces of code will add all the even numbers between 0 and 8 (including 0 and 8, 0 is an even number, sum starts at 0)? int x; is declared for all of them.

a. for (x=0; x<=9; x+=2)

{

sum = sum + x;

}

b. for (x=0; x<=8; x++)

{

sum = sum + 2 * x;

}

c. for (x=0; x<=8; x++)

{

sum = sum + x;

}

d. for (x=0; x<=8; x+=2)

{

sum = sum + x(even);

}

e. none of the above

a. for (x=0; x<=9; x+=2)

{

sum = sum + x;

}

11
New cards

Which of the following will add the item "Bananas" to the list box 1stList?

a. 1stList.Items.Add("Bananas");

b. 1stList[x].Items.Add("Bananas");

c. 1stList.Items.Add.Bananas;

d. 1stList(x) = "Bananans";

e. None of these

a. 1stList.Items.Add("Bananas");

12
New cards

An array is a series of memory locations that share the same _______.

a. frame

b. events.

c. memory loactions

d. name

e. none of these

d. name

13
New cards

What is the value of X after the loops have both executed?

int X=0;

while (X < 3);

{

X += 2;

while ((X >= 2) && (X < 5))

{

X += 3;

}

}

a. 0

b. 2

c. 5

d. 10

e. none of these

c. 5

14
New cards

When the GO button is pushed: What is the value of A displayed in the message box in the sub btnGO_Click?

public int FunOne (ref int X, int Y)

{

do

{

X = X + X * X;

} while (X <= 10);

Y = Y * 2;

MessageBox.Show(X + " " + Y);

switch (Y) {

case 8: return (Y + X);

case 14: return (Y - X);

default: return (X + Y);

}

}

private void btnGO_Click(object sender, Event Args e)

{

int A, F, G;

A = 7;

F = 4;

G = FunOne(ref F, A);

MessageBox.Show(A.ToString() + " " + F.ToString() + " " + G.ToString());

a. -6

b. 14

c. 20

d. 7

e. none of these

d. 7

15
New cards

What is the value of F displayed in the message box in the sub btnGO_Click?

public int FunOne (ref int X, int Y)

{

do

{

X = X + X * X;

} while (X <= 10);

Y = Y * 2;

MessageBox.Show(X + " " + Y);

switch (Y) {

case 8: return (Y + X);

case 14: return (Y - X);

default: return (X + Y);

}

}

private void btnGO_Click(object sender, Event Args e)

{

int A, F, G;

A = 7;

F = 4;

G = FunOne(ref F, A);

MessageBox.Show(A.ToString() + " " + F.ToString() + " " + G.ToString());

a. 20

b. 14

c. 7

d. 4

e. none of these

a. 20

16
New cards

What is the value of G displayed in the message box in the sub btnGO_Click?

public int FunOne (ref int X, int Y)

{

do

{

X = X + X * X;

} while (X <= 10);

Y = Y * 2;

MessageBox.Show(X + " " + Y);

switch (Y) {

case 8: return (Y + X);

case 14: return (Y - X);

default: return (X + Y);

}

}

private void btnGO_Click(object sender, Event Args e)

{

int A, F, G;

A = 7;

F = 4;

G = FunOne(ref F, A);

MessageBox.Show(A.ToString() + " " + F.ToString() + " " + G.ToString());

a. -6

b. 7

c. 34

d. 0

e. none of these

a. -6

17
New cards

What is the value of Y displayed in the message box in the function FunOne?

public int FunOne (ref int X, int Y)

{

do

{

X = X + X * X;

} while (X <= 10);

Y = Y * 2;

MessageBox.Show(X + " " + Y);

switch (Y) {

case 8: return (Y + X);

case 14: return (Y - X);

default: return (X + Y);

}

}

private void btnGO_Click(object sender, Event Args e)

{

int A, F, G;

A = 7;

F = 4;

G = FunOne(ref F, A);

MessageBox.Show(A.ToString() + " " + F.ToString() + " " + G.ToString());

a. 7

b. 20

c. -6

d. 14

e. none of these

d. 14

18
New cards

What is the value of X displayed in the message box in the function FunOne?

public int FunOne (ref int X, int Y)

{

do

{

X = X + X * X;

} while (X <= 10);

Y = Y * 2;

MessageBox.Show(X + " " + Y);

switch (Y) {

case 8: return (Y + X);

case 14: return (Y - X);

default: return (X + Y);

}

}

private void btnGO_Click(object sender, Event Args e)

{

int A, F, G;

A = 7;

F = 4;

G = FunOne(ref F, A);

MessageBox.Show(A.ToString() + " " + F.ToString() + " " + G.ToString());

a. 14

b. 4

c. 7

d. 0

e. none of the above

e. none of the above

19
New cards

if we wanted to use MSChart control to plot 5 points of the function (x^2) from Xmin=0 to Xmax=2, we would use the following code:

for (x=0; x<=2; x+=Q) //5 slots for 0 to 2, inclusive

{

chtMyChart.Series[0].Points.AddXY(G, G ^ 2);

}

What is the correct equation for Q? Assume that Xmin and Xmax are the minimumand maximum values to be displayed on the charts x-axis. this is similar to lab 6.

a. Q = (Xmin + 4) * (Xmax - Xmin);

b. Q = (Xmax - Xmin) / 4;

c. Q = ((x - 1) / 5) * (Xmax - Xmin);

d. Q = (1 / 5) * (Xmax - Xmin);

e. none of these

b. Q = (Xmax - Xmin) / 4;

20
New cards

the chtMyChart.Series[0].Points.Clear() for Microsoft Chart Control is used for

a. clearing all of the points on the graph

b. changing the type of graph to a bar graph

c. clearing one point on a graph

d. clearing the form

e. none of the above

a. clearing all of the points on the graph

21
New cards

which of the following function/sub routine declarations are incorrect, that is, they will not work in Visual C#.NET?

a. public void mySub(String Var, ref int V1)

b. private sting mySub(int V1)

c. public method myFunc(ref int V1)

d. private void mySub()

e. they are all correct

c. public method myFunc(ref int V1)

22
New cards

in lab 7 you were required to open a file and read all of the data from it. Which of the following statements properly opens this file?

System.IO.StreamReader myFile;

a. myFile = System.IO.File.OpenText ("c: \\ egr1400 \\ famous.txt");

b. myFile = OpenText ("c: \\ egr1400 \\ famous.txt");

c. myFile.File.OpenText ("c: \\ egr1400 \\ famous.txt");

d. File.OpenText ("c: \\ egr1400 \\ famous.txt") = myFile;

e. none of the above

a. myFile = System.IO.File.OpenText ("c: \\ egr1400 \\ famous.txt");

23
New cards

what type of structured file contains both data and field names for the data making it possible to use LINQ to retrieve the data?

a. TXT file

b. XML file

c. SQL file

d. XLS file

e. none of the above

b. XML file

24
New cards

which of the following declarations properly accepts an array of strings as an input parameter?

a. public void (ref string myStr[sizeofarry] //where sizeofarry is a number

b. public void (string myStr[4])

c. public void (string ref myStr[15])

d. public void (string[ ] myStr)

e. public void (strings myStr)

d. public void (string[ ] myStr

25
New cards

you display message boxes with the built-in MessageBox. _____ method.

a. PutMSG

b. PopUp

c. Message

d. Show

e. none of these

d. Show

26
New cards

in lab 5, the craps game, we defined two states, one for the first roll and another for rolls after the first roll. the variable that we used for that state was

a. a module variable

b. a button-level variable

c. a form-level variable

d. a project-level global universal variable

e. an array

c. a form-level variable

27
New cards

given the structure for recording experimental results in the box below, which of the following statements correctly declares an array of these structures that will hold 10 experiments?

_____________________________________

| |

| struct Experiment |

| { |

| public int ExptNum; |

| public double Temp; |

| public int Humidity; |

| } |

-----------------------------

a. Experiment[ ] Expts = new Experiment[9];

b. Experiment[ ] Expts = new Experiment[10];

c. Experiment[10] Expts = new Experiment[10];

d. string[ ] Expts = new Experiment[10];

e. none of these

b. Experiment[ ] Expts = new Experiment[10];

28
New cards

which of the following statements correctly sets the tempurature to 54.5 degrees in the array declared in #27 for the temperture in Expts[4]?

a. Expts.Temp[4] = 54.5;

b. Expts[4][Temp] = 54.5;

c. Expts[4].Temp = 54.5;

d. Expts[4] = 54.5;

e. none of these

c. Expts[4].Temp = 54.5;

29
New cards

what is the value of A[5] after the code has been executed?

int[ ] A = new int[5];

int x;

for (x = 0; x < 5; x++)

{

A[x] = x^2 + (x * 2);

}

a. 15

b. 25

c. 10

d. 0

e. none of these, A[5] is invalid

e. none of these, A[5] is invalid

30
New cards

he best type of loop to use for reading from all data of a file is a ________ loop.

a. repetitive

b. for

c. while

d. counter

c. while

31
New cards

if you were to run a Monte Carlo Simulation, how many iterations would yield the best results, more accurate and representative of the "real world' than the other answers?

a. 10

b. 100

c. 1000

d. 10000

e. 100000

e. 100000

32
New cards

in Visual C# .NET the .Next method of the Random type of variable gives a random number from a _________ distribution.

a. unit-scalar

b. polynomial

c. normal

d. uniform

e. none of these

d. uniform

33
New cards

in lab 7 we used the string's Split method to split a string of values separated by a comma into an array. given the code below, what is the value of values[2]?

string s = "12, 34, 56, 78";

string[ ] values = s.Split(' , ');

a. 34

b. 78

c. 00

d. 56

e. none of these

d. 56

34
New cards

the graph produced by a Monte Carlo Simulation shows the output ranges on the x-axis while the y-axis contains

a. the number of times that the resulting output occurred within the range on the corresponding x-axis

b. the number of bins

c. the number of times that of of the input variables occurred within the range on the corresponding x-axis

d. the number of times the Monte Carlo Simulation was run

a. the number of times that the resulting output occurred within the range on the corresponding x-axis