Comp Sci Final
What relational operator is used to mean "not equal"?
!=
Which of the following file extensions is most likely to contain source code?
*.cs
What of these is not a relational operator?
+
What is the name if Microsoft's library of pre-built methods and components that work with multiple languages?
.NET Framework
How many check boxes can be selected on the screen at one time?
0, 1, or more
How many radio buttons can be selected within one group at a time?
1 only
What C# component represents an application screen that contains other controls?
A Form
What is the difference between a group of RadioButtons and a group of CheckBoxes?
A RadioButton group will only allow one selection, a CheckBox group will allow multiple selections
What is an IDE?
A central place to write, build, run, and debug code
What is the primary difference between compiling a program and interpreting it?
A compiled program is translated from human-readable code to native machine language, which is then sent to the target computer. An interpreted program sends the source code to an interpreter on the target machine. The interpreter will translate the code into native machine language.
What is a class?
A group of functions and data that work together to perform a task
Which of the following best describes the .Net Framework?
A library of pre-built functions that can be accessed from multiple languages.
What does a reference variable hold?
A link data or an object somewhere else in memory
What is the relationship between projects and solutions in Visual C#?
A solution can contain one or more products
What is a "project"?
A way to organize all the elements needed to create a single program
Which of the following best describes namespaces?
A way to organize groups of objects into hierarchies
It's usually a good idea to do what near a text box?
Add a descriptve label so the user knows what to do
How would you make the value of a variable unchangeable within a program?
Add the "const" keyword in front of the variable declaration
Where should you declare a variable that you only want to use within one function?
At "local" scope
When is the index value evaluated in the for loop sequence?
At the beginning of the loop
When is the logical expression tested within a "while" loop?
At the top of the loop
Which of the following is an advantage of the C# language over the C language?
C# is an object-oriented language from the ground up, C# contains automatic memory management, C# supports the .NET Framework, (All of these)
How can you change the caption or title of a Form?
Change the "Text" property in the Property panel
What is "white space"?
Characters like spaces, tabs, carriage returns, or line-feeds that make your code easier to read
What property shows that a radio button or check box control has been selected?
Checked
C# source code is compiled into what format?
Common Intermediate Language (CIL)
What function will display a single line of text to the screen?
Console.WriteLine()
What does it mean to "cast" a variable?
Convert variable values from one data type to another
What will the code "MessageBox.Show("Greetings");" do?
Display a pop-up dialog with "Greetings" and an OK button
What does a "while" loop do?
Executes a block of code as long as some logical expression is true
Which of the following best describes event-driven programming?
Executing functions or blocks of code in response to some event
What does a file extension do?
Give the operating system a hint as to how to handle the file contents
What type of loop never stops executing?
Infinite loop
What property would you set in the Property panel to add choices to a list or combo box control?
Items
Considering the following code, what lines are executed if the value in "age" is 12? 1 if (age>18) 2 bool isOldEnough = true; 3 MessageBox.Show("You're old enough!");
Lines 1 and 3
What is the difference between list boxes and combo boxes?
List boxes display all items at once, but combo boxes display one item at a time.
What is a "for" loop?
Loop will execute a block of code a fixed number of times
What are scroll bars used for?
Moving text box displays up/down or left/right to view additional text
What type of code will change the text on a button named "MyButton" to "Click Here"?
MyButton.Text="Click Here";
Which of the following best describes a variable?
Named places to store data in your program
How do parentheses help to clarify a math statement?
Operators in parentheses will execute first regardless of precedence rules, parentheses make it more obvious to a human reader what will happen, (both of these)
What do operator precedence rules determine?
Order of execution of multiple mathematical operators within an expression
What is wrong with the following code? string myString = "mystery"; char last = myString[7];
Run-time error because the index is too large
END OF 2
START 3
END OF 3
START 4
END OF 4
START 5
END OF 5
START 6
END OF 6
START 7
What property would you read or set to manage the currently chosen item by index in a list or combo box control?
SelectedIndex
How do you set the caption displayed by a Label control?
Set the Text attribute
What does the initialization statement do in a "for" loop?
Sets the loop's index variable to a starting value
Which of the following is NOT a common form element?
Shape Box
Is a text box control single-line or multi-line by default?
Single-line
Why would a programmer need to un-hide a file extension?
So you can tell the difference between similarly named files
What build-in data type can be used to store the text entered by a user?
String
Assuming you have a TextBox control named "addressTextBox" on your Form, how would you retrieve any text in this control?
String myAddress = addressTextBox.Text;
How can you create more than one group of radio buttons on the screen?
Surround each set of radio buttons with a group box control
What namespace contains the "Forms" object?
System.Windows.Forms
If we created a namespace called "TeenCoder", which contained a namespace called "Windows" which contained a namespace called "Programming", how would we reference the "Programming" namespace in our code?
TeenCoder.Windows.Programming
What property of the text box control would you read or set to manage the string shown in the control?
Text
What is the purpose of the Controls Toolbox?
The Controls Toolbox holds all the possible Windows controls that can be added to a Form
What is the difference between the Enabled and Visible properties for the TextBox control?
The Enabled property indicates whether or not the user can use the TextBox. The Visible property indicates whether or not the user can see the TextBox.
What property is used to allow a user to enter more than one line of text into TextBox?
The Multiline property
What is the difference between the Write() and WriteLine() methods?
The WriteLine() method will put the cursor on the next line on the screen, the Write() method will not
How does the compiler know that we have reached the end of a code statement?
The end of a statement is marked by with semicolons ";"
When using the ReadLine() method, what character is discarded?
The newline character
How does the Console.ReadLine() function know the user is done entering text?
The user will press Enter to add a newline character
What is the main difference between a while loop and a do-while loop?
The while loop tests the logical expression at the top of the loop. The do-while loop tests the logical expression at the bottom of the loop
What would be the output of the following code: for (int = 4; i >= 0; i--) { MessageBox.Show(i.ToString()); }
This code will show 5 pop-up windows with the values: 4, 3, 2, 1, and 0
What is stored in myString as a result if the following code: string myString = "Three" + "Blind" + "Mice";
ThreeBlindMice
How do you manage the attributes of a control from the Design Screen?
Through the "Properties" panel
What is an "if" statement used for in a program?
To execute a block of code if a condition is true
Why do you add "using" statements to the top of your code?
To let you access an object from the namespace using only the short name
What is a compound logical expression?
Two or more logical expressions joined by a logical operator
Which of the following events can be used to trigger a function call in your program?
User clicks a button, User types into a control, User moves the mouse, (all of the above)
What is wrong with the variable name "321_liftoff"?
Variable names cannot begin with numbers
What type of project is used to create a graphical program in Visual C#?
Windows Forms Application
If you wanted to use a method called "mystery()" on an object named "X" in namespace "Y.Z", how would you access the mystery() method without using a statement?
Y.Z.X.mystery();
Do you add items to a ListBox control from the IDE or through code statements?
You can choose to add items through the IDE's Property Panel or through code statements
What is the major difference between radio buttons and check boxes?
You can only select one radio button in a group at a time; you can select 0, 1, or more check boxes
Why is it important to give forms and controls meaningful names?
You can't identify the purpose of a control when reading the name in your code
What is the one thing you must ALWAYS do inside a while loop?
You must include some statements that will affect the logical expression and allow the loop to exit
If you compare two object references with the equality operator ==, what will be the result?
You will know if the references are identical, but not whether or not the objects are equal
Assuming we have a CheckBox named petCheckBox, which line of code will retrieve the current state of that CheckBox?
bool isChecked = petCheckBox.Checked;
What keyword can be used to exit a loop immediately regardless of the test condition?
break
What type of "while" loop will always be executed at least once?
do-while
Scroll bars are automatically added to any multi-line TextBox
false
Which of the following if statements are NOT valid:
if (myAge = 18)
Which statement below declares and initializes an "int" variable named "myVar" with the value -4765 ?
int myVar = -4765;
What is the result of the following code: string myString1 = "GRUMPY"; string myString2 = "Grumpy"; bool isEqual = myString1.Equals(myString2, StringComparison.OrdinalIgnoreCase);
isEqual = true
What function will be called automatically when your program starts?
main()
Assuming we have a ListBox control named myChoices, what line of code will clear all items from the ListBox control?
myChoices.Clear();
All the objects in C# are carefully organized into ______.
namespaces
What keyword is necessary to create an object to store in a reference variable?
new
What is the value of a reference variable that does not refer to anything?
null
What line of code will select a RadioButton named redRadio?
redRadio.Checked = true;
What is the value of result in the following logical expression? bool result = (1<2) || (3>5)
result = true
What line of code will allow you to retrieve the value of the currently selected item from our myChoices ListBox?
string choice = myChoices.Text;
What are the two possible results of evaluating a logical expression?
true or false
Given x = 0; which of the following two statements adds 3 to "x" and then multiplies "x" by 5?
x+=3; x*=5;