final Flashcards
The ________ is used to perform string concatenation.
&
In a program, you clear a text box with code ________________.
by assigning the empty string to the text property
Variables declared within a button’s click-event are ____________ variables
local
What has the highest order of precedence in arithmetic expressions?
Exponentiation
A ______ control can display arrays in a scrollable grid.
DataGridView
The result of the following is __.
string str = “Spring”;
char c = str[2];
MessageBox.Show(c.ToString());
r
A(n) __________ is an object that can hold a group of values that are all of the same data type.
array
Each element in an array is assigned a unique number known as a(n) _____________.
subscript or index
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]; }
}
b)
int max = n[0];
for (int i = 1; i < n.Length; i++)
{ if (n[i] > max)
{ max = n[i]; }
}
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
c) a = 7, b = 5
What loop performs an iteration before testing its Boolean expression?
do-while
What method will erase all the items in a listbox?
items.Clear();
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”;
}
c)
if (payAmount >= 1200 && payAmount <= 1400)
{
lblMessage.text = “Pay amount is in the range”;
}
What is the purpose of using the following type of structure?
try
{ some statements; }
catch
{ some statements; }
to catch any run-time errors such as divide-by-zero and not have the program shut down or crash
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;
33.0
When the user selects a file with the Open dialog box, the file’s path and filename are stored in the control’s ________.
Filename property
The _______ displays a standard Windows Save As dialog box.
SaveFileDialog control
What is the difference between a void method and a value-returning method?
A value-returning method must return a value back through its name and a void method cannot.
When you want to write data to a text file, you use the __________ class.
StreamWriter
When you want to read data from a text file you use the _____________ class.
StreamReader
StreamReader objects have a Boolean property named ______________ that signals whether the end of a text file has been reached.
EndOfStream
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
b) a=10 b=5
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);
c) count = 5
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();
The three elements of subject array will be written to the “data.txt” file’s contents.
The money data type is the _______ data type defined in C#.
decimal
true or false?
string str = “1a3b5”;
if (char.IsDigit(str, 2))
{ MessageBox.Show(“True”); }
else
{ MessageBox.Show(“False”); }
true
What does the messagebox show?
string str = “chocolate ice cream”;
int position = str.IndexOf(“ice”);
if (position != -1)
{ MessageBox.Show(position.ToString()); }
9
- true or false?
Before adding an item to listbox the size of the listbox must be known first.
false
What is the value of i at the conclusion the loop?
int i=0;
while (i<3)
{ i++; }
3
What is the value of oneDollar?
double amount=20;
decimal oneDollar;
oneDollar = 5 * amount;
logical error
You can use the ______________ property to determine whether an item is selected in a ListBox.
SelectedIndex
What loop is a pretest that first initializes a counter variable and then increments the counter variable at the end of each iteration?
for
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; }
d)
private double average(int a, int b, int c)
{ return (a + b + c)/3.0; }
A ListBox object has a ____________ that holds the number of items stored in the ListBox.
Count property
A ______ is any hypothetical person using a program and providing input for it.
user
If a ListBox contains 100 items. What is the highest SelectedIndex value?
99
In C#, all arrays have a _____________ that is set to the number of elements in the array.
Length property
The ______________ uses a loop to sequentially step through an array, starting with the first element.
sequential search algorithm
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.
c) Class-Level variables can be accessed by any method in the same form.
A byte is made up of eight _________.
bits
A common operation performed on strings is _______, or appending one string to the end of another.
concatenation
A programmer, or software developer, is a person with the training and skills necessary to _____, _____, & _____ computer programs.
design
create
test
A(n) ________ is a mistake such as a misspelled keyword, a missing punctuation character, or the incorrect use of an operator.
syntax error
A ________ holds only one value at a time.
variable
A piece of data that is passed into a method is known as a(n) ________.
argument
Math expression involving a double and a(n) ________ are not allowed unless a cast operator is used to convert one of the operands.
decimal
The order in which controls receive the focus is called the ________.
tab order
- true or false?
All it takes for an && expression to be true is for one side of the && operator to be true.
false
- true or false?
For an || expression to be true, the expression on the left side of the || operator must be false.
false
Anytime a RadioButton or a CheckBox control’s Checked property changes, a ________ happens for that control.
CheckChanged event
A string can be converted to a decimal with the ________ method.
decimal.TryParse
RadioButton controls have a ________ property that determines whether the control is selected or deselected.
Checked
When the user selects an item in a ListBox, the item’s index is stored in the Listbox’s ________ property.
SelectedIndex
A value-returning statement must have a(n) ________ statement.
return
When this method is finishes, a value passed back to the calling module by invoking the return statement.
value-returning method
When an argument is ________, only a copy of the argument’s value is passed into the parameter variable.
passed by value
Which of the following data types can be returned from a method?
a) int
b) bool
c) string
d) any of these
d) any of these
Each time the loop executes its statement or statements, we say the loop is iterating, or performing a(n) ________.
iteration
Files on disk are identified by a(n) ________.
filename
If a loop does not have a way of stopping, it is called a(n) ________.
infinite loop
If the user clicks the Open button, the OpenFileDialog control’s ShowDialog method returns the value ________.
DialogResult.OK
The .NET Framework provides a class named ________ that you can use in C# to generate random numbers.
Random
The increment operator is ________.
++
When you run an application, the application’s form is loaded into memory and an event known as the ________ takes place.
load event
When you want to read data from a text file, you create a file object using the ________.
StreamReader
In C#, ________ are enclosed in single quotation marks.
character literals
Which one of the following values is stored in the letter variable?
string tree = “Pear”;
char letter = tree[3];
r
- true or false?
You should use try-catch statements primarily for those exceptions that are beyond your control.
true
When an argument is passed by [this] method, only a copy of the contents of the argument is passed to the method.
passed by value
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
.csv file
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
d) all of the above
Referring to the Diving Scores program, which sorting algorithm was used to sort the data?
selection
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
b) BooksClass MyRef = new BooksClass();
- true or false?
The debugger in Visual Studio is a great tool to find LOGICAL errors in a computer program.
true
- true or false?
The debugger in Visual Studio is a great tool to find SYNTAX errors in a computer program.
false
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; }
}
}
1000
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]);
30
- true or false?
If the argument is already uppercase, the char.ToLower method returns it unchanged.
true
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
d) length >= width
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
b) lstName.Items.RemoveAt(4);
A ________ object displays text on a form.
label
When the computer is turned off, the contents of ________ are erased.
RAM
To close an application’s form in code, you use the statement ________.
this.Close();
- 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.
true
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
b) 2.5
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
c) 3.0