final Flashcards

1
Q

The ________ is used to perform string concatenation.

A

&

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

In a program, you clear a text box with code ________________.

A

by assigning the empty string to the text property

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

Variables declared within a button’s click-event are ____________ variables

A

local

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

What has the highest order of precedence in arithmetic expressions?

A

Exponentiation

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

A ______ control can display arrays in a scrollable grid.

A

DataGridView

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

The result of the following is __.

string str = “Spring”;
char c = str[2];
MessageBox.Show(c.ToString());

A

r

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

A(n) __________ is an object that can hold a group of values that are all of the same data type.

A

array

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

Each element in an array is assigned a unique number known as a(n) _____________.

A

subscript or index

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

Given the following code, which can find the maximum value in the array?

int[] n = { 16, 3, 7, 18, 21 };

a)
int max = n[0];
for (int i = 1; i < n.Length-1; i++)
{ if (n[i] > max)
{ max = n[i]; }
}

b)
int max = n[0];
for (int i = 1; i < n.Length; i++)
{ if (n[i] > max)
{ max = n[i]; }
}

c)
int max = n[0];
for (int i = n.Length-1; i>=1; i–)
{ if (n[i] < max)
{ max = n[i]; }
}

d)
int max = n[1];
for (int i = n.Length-1; i>=1; i–)
{ if (n[i] < max)
{ max = n[i]; }
}

A

b)
int max = n[0];
for (int i = 1; i < n.Length; i++)
{ if (n[i] > max)
{ max = n[i]; }
}

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

The result of the following is _____.

int a = 5;
int b = 7;
int c = a;
a = b;
b = c;

MessageBox.Show(“a = “ + a + “, b = “ + b);

a) a = a, b = b
b) a = 5, b = 7
c) a = 7, b = 5
d) a = b, b = a

A

c) a = 7, b = 5

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

What loop performs an iteration before testing its Boolean expression?

A

do-while

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

What method will erase all the items in a listbox?

A

items.Clear();

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

You want to determine whether a variable, payAmount , is between 1200 and 1400 inclusively (1200 & 1400 included).

If the value is in the range the label lblMessage should contain the string “Pay amount is in the range”.

Which of the following code segments will accomplish this?

a)
if (payAmount >= 1200 && <= 1400)
{
lblMessage.text = “Pay amount is in the range”;
}

b)
if (payAmount >= 1200 || payAmount <= 1400)
{
lblMessage.text = “Pay amount is in the range”;
}

c)
if (payAmount >= 1200 && payAmount <= 1400)
{
lblMessage.text = “Pay amount is in the range”;
}

d)
if (payAmount > 1200 && payAmount < 1400)
{
lblMessage.text = “Pay amount is in the range”;
}

A

c)
if (payAmount >= 1200 && payAmount <= 1400)
{
lblMessage.text = “Pay amount is in the range”;
}

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

What is the purpose of using the following type of structure?

try
{ some statements; }
catch
{ some statements; }

A

to catch any run-time errors such as divide-by-zero and not have the program shut down or crash

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

What is the value of outCome after the following section of code is executed?

decimal A = 6.0m;
double B = 2.0;
double C = 3 * (double)A/B;
double outCome = 2 * C + 15;

A

33.0

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

When the user selects a file with the Open dialog box, the file’s path and filename are stored in the control’s ________.

A

Filename property

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

The _______ displays a standard Windows Save As dialog box.

A

SaveFileDialog control

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

What is the difference between a void method and a value-returning method?

A

A value-returning method must return a value back through its name and a void method cannot.

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

When you want to write data to a text file, you use the __________ class.

A

StreamWriter

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

When you want to read data from a text file you use the _____________ class.

A

StreamReader

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

StreamReader objects have a Boolean property named ______________ that signals whether the end of a text file has been reached.

A

EndOfStream

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

What is the output of the following code?

int a = 5;
int b = 10;
SwitchValues(ref a,ref b);
MessageBox.Show(“a=”+a +” “+”b=”+ b);

public void SwitchValues(ref int a,ref int b)
{
int temp = a;
a = b;
b = temp;
}

a) a=5 b=10
b) a=10 b=5
c) a=a b=b
d) a=b b=a

A

b) a=10 b=5

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

The modulus operator (%) computes the remainder after dividing its first operand by its second. For example 3 % 2 is 1 and 4 % 2 is 0. What is the output of the following code?

(Hint: Write it down and don’t do it in your head.)

int[] a = new int[10];
int count=0;
for (int index = 0; index < a.Length; index++)
{ a[index] = index + 1; }

for (int index = 0; index < a.Length; index++)
{
if (a[index] % 2 == 0)
{ count++; }
}
MessageBox.Show(“count=” + count);

A

c) count = 5

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

According to the following, which statement is correct?

StreamWriter outputFile;
outputFile = File.CreateText(“data.txt”);
string[] subject = { “Biology”, “Chemistry”, “Physics” };

for (int i=0; i<subject.Length; i++)
{ outputFile.WriteLine(subject[i]); }

outputFile.Close();

A

The three elements of subject array will be written to the “data.txt” file’s contents.

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

The money data type is the _______ data type defined in C#.

A

decimal

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

true or false?

string str = “1a3b5”;

if (char.IsDigit(str, 2))
{ MessageBox.Show(“True”); }

else
{ MessageBox.Show(“False”); }

A

true

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

What does the messagebox show?

string str = “chocolate ice cream”;
int position = str.IndexOf(“ice”);

if (position != -1)
{ MessageBox.Show(position.ToString()); }

A

9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q
  • true or false?
    Before adding an item to listbox the size of the listbox must be known first.
A

false

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

What is the value of i at the conclusion the loop?

int i=0;
while (i<3)
{ i++; }

A

3

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

What is the value of oneDollar?

double amount=20;
decimal oneDollar;
oneDollar = 5 * amount;

A

logical error

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

You can use the ______________ property to determine whether an item is selected in a ListBox.

A

SelectedIndex

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

What loop is a pretest that first initializes a counter variable and then increments the counter variable at the end of each iteration?

A

for

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

Which of the following code is a correctly written value-returning method Average that will accept three integers as parameters, calculate their average, and return the result?

a)
private double average(int a, int b, int c)
{ average = (a + b + c)/3.0; }

b)
private double average(out int a, out int b, out int c)
{ average = (a + b + c)/3.0; }

c)
private double average (int a, int b, int c, double average)
{ average = (a + b + c)/3.0; }

d)
private double average(int a, int b, int c)
{ return (a + b + c)/3.0; }

A

d)
private double average(int a, int b, int c)
{ return (a + b + c)/3.0; }

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

A ListBox object has a ____________ that holds the number of items stored in the ListBox.

A

Count property

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

A ______ is any hypothetical person using a program and providing input for it.

A

user

36
Q

If a ListBox contains 100 items. What is the highest SelectedIndex value?

A

99

37
Q

In C#, all arrays have a _____________ that is set to the number of elements in the array.

A

Length property

38
Q

The ______________ uses a loop to sequentially step through an array, starting with the first element.

A

sequential search algorithm

39
Q

Which of the following is true regarding the use of Class-Level variables?

a) You should use Class-Level variables as much as possible in order to reduce the amount of memory used by your program.
b) You must declare the use of Class-Level variables in every method that uses the variable.
c) Class-Level variables can be accessed by any method in the same form.
d) Class-Level variables must be declared inside the first method called on the form.

A

c) Class-Level variables can be accessed by any method in the same form.

40
Q

A byte is made up of eight _________.

A

bits

41
Q

A common operation performed on strings is _______, or appending one string to the end of another.

A

concatenation

42
Q

A programmer, or software developer, is a person with the training and skills necessary to _____, _____, & _____ computer programs.

A

design
create
test

43
Q

A(n) ________ is a mistake such as a misspelled keyword, a missing punctuation character, or the incorrect use of an operator.

A

syntax error

44
Q

A ________ holds only one value at a time.

A

variable

45
Q

A piece of data that is passed into a method is known as a(n) ________.

A

argument

46
Q

Math expression involving a double and a(n) ________ are not allowed unless a cast operator is used to convert one of the operands.

A

decimal

47
Q

The order in which controls receive the focus is called the ________.

A

tab order

48
Q
  • true or false?
    All it takes for an && expression to be true is for one side of the && operator to be true.
A

false

49
Q
  • true or false?
    For an || expression to be true, the expression on the left side of the || operator must be false.
A

false

50
Q

Anytime a RadioButton or a CheckBox control’s Checked property changes, a ________ happens for that control.

A

CheckChanged event

51
Q

A string can be converted to a decimal with the ________ method.

A

decimal.TryParse

52
Q

RadioButton controls have a ________ property that determines whether the control is selected or deselected.

A

Checked

53
Q

When the user selects an item in a ListBox, the item’s index is stored in the Listbox’s ________ property.

A

SelectedIndex

54
Q

A value-returning statement must have a(n) ________ statement.

A

return

55
Q

When this method is finishes, a value passed back to the calling module by invoking the return statement.

A

value-returning method

56
Q

When an argument is ________, only a copy of the argument’s value is passed into the parameter variable.

A

passed by value

57
Q

Which of the following data types can be returned from a method?

a) int
b) bool
c) string
d) any of these

A

d) any of these

58
Q

Each time the loop executes its statement or statements, we say the loop is iterating, or performing a(n) ________.

A

iteration

59
Q

Files on disk are identified by a(n) ________.

A

filename

60
Q

If a loop does not have a way of stopping, it is called a(n) ________.

A

infinite loop

61
Q

If the user clicks the Open button, the OpenFileDialog control’s ShowDialog method returns the value ________.

A

DialogResult.OK

62
Q

The .NET Framework provides a class named ________ that you can use in C# to generate random numbers.

A

Random

63
Q

The increment operator is ________.

A

++

64
Q

When you run an application, the application’s form is loaded into memory and an event known as the ________ takes place.

A

load event

65
Q

When you want to read data from a text file, you create a file object using the ________.

A

StreamReader

66
Q

In C#, ________ are enclosed in single quotation marks.

A

character literals

67
Q

Which one of the following values is stored in the letter variable?

string tree = “Pear”;
char letter = tree[3];

A

r

68
Q
  • true or false?
    You should use try-catch statements primarily for those exceptions that are beyond your control.
A

true

69
Q

When an argument is passed by [this] method, only a copy of the contents of the argument is passed to the method.

A

passed by value

70
Q

A text file formatted as following is called _______.

Billy, Bailey, 4.52
Joe, Green, 3.32
Ted, Smith, 2.3
John, Jones, 3.2
Betty, Frank, 5.2

A

.csv file

71
Q

Which statement is true given the following for statement?

for (i = 3; i < 20; i++)
{ }

a) The initialization express is i=3
b) The test expression is i < 20
c) The update expression is i++
d) All of the above are true

A

d) all of the above

72
Q

Referring to the Diving Scores program, which sorting algorithm was used to sort the data?

A

selection

73
Q

Which statement create an instance of the BooksClass with reference MyRef?

a) MyRef = new BooksClass;
b) BooksClass MyRef = new BooksClass();
c) BooksClass MyRef = BooksClass();
d) All of the above

A

b) BooksClass MyRef = new BooksClass();

74
Q
  • true or false?
    The debugger in Visual Studio is a great tool to find LOGICAL errors in a computer program.
A

true

75
Q
  • true or false?
    The debugger in Visual Studio is a great tool to find SYNTAX errors in a computer program.
A

false

76
Q

What is the final value of count?

int count = 0;

for (int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
for (int k=0; k<10; k++)
{ count = count + 1; }
}
}

A

1000

77
Q

What is the value of var after executing the following code?

string temp = Bob:Smith:10:20:30:40
string[] tokens = temp.Split(‘:’);
var = int.Parse(tokens[4]);

A

30

78
Q
  • true or false?
    If the argument is already uppercase, the char.ToLower method returns it unchanged.
A

true

79
Q

Which one of the following expressions determines whether the value of the length variable is greater than or equal to the value of the width variable?

a) length < width
b) width <= length
c) length > width
d) length >= width

A

d) length >= width

80
Q

Which statement below will remove the 5th item from listbox lstName?

a) lstName.RemoveAt(4);
b) lstName.Items.RemoveAt(4);
c) lstName.RemoveIndexAt(4);
d) None of the above

A

b) lstName.Items.RemoveAt(4);

81
Q

A ________ object displays text on a form.

A

label

82
Q

When the computer is turned off, the contents of ________ are erased.

A

RAM

83
Q

To close an application’s form in code, you use the statement ________.

A

this.Close();

84
Q
  • true or false?
    Given the statement, “Random rand = new Random();”, the expression new Random() causes an object of the Random class to be created in memory.
A

true

85
Q

What is the Overall GPA?

ETM 2080 3.0 A
ETM 2180 3.0 B
ETM 3030 3.0 C
CHEM 1210 3.0 D

a) 2.0
b) 2.5
c) 3.0
d) none of the above

A

b) 2.5

86
Q

What is the ETM GPA?

ETM 2080 3.0 A
ETM 2180 3.0 B
ETM 3030 3.0 C
CHEM 1210 3.0 D

a) 2.0
b) 2.5
c) 3.0
d) none of the above

A

c) 3.0

87
Q
A