• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/100

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

100 Cards in this Set

  • Front
  • Back
The C# __________________ builds the source code in a C# source file into an executable file.
compiler
IDE stands for ____________________________ .
Integrated Development Environment
The ________________ property of a text box lets you prevent the user from entering data into the control.
ReadOnly
To provide for a user entry, you use a ________________ control.
textBox
The CancelButton property of a form sets the button that will be activated if the user presses the _________________ key.
Esc
The properties, methods, and events of a class are called the ___________________ of the class.
members
When you change the name of a variable in your C# code, Visual Studio will ask whether you want to change all of the other uses of that name through a feature known as _______________.
refactoring
When you use the methods of the Math class, you don’t create an object from the class. Instead, you use the _____________ methods of the class.
static
To convert a decimal variable’s data to a string, you can use the _______________ method of the variable.
ToString
By default, you can assign a null value to a variable that’s a reference type. But to assign a null value to a variable that’s a value type, you need to declare the variable as a _________________.
nullable type
Write a statement that declares a string variable named cityAndState and assigns a starting value of Cleveland.
string cityAndState = "Cleveland";
To implement the case structure, you use a/an ______________ statement.
switch
An object that’s used to connect an event to an event handler is known as a ______________.
delegate
When an error occurs during the execution of a method, the method ____________ an exception.
throws
The list of methods that were called before an exception occurred is called the ________________.
stack trace
To get a description of an exception that has been caught, you can use the exception’s ______________ property.
StackTrace or Message
If a value that’s assigned to an int variable is too large to be stored in it, a/an ______________ exception occurs.
overflow
One way to code a method that calls generic methods to test the validity for all of the user entries of a form is to code one ______________ statement for each method call and return a false value if the generic method returns a false value.
throw
When you use a foreach loop to work with the elements in an array, the statements in the loop are executed once for each __________________ in the array.
element
A two-dimensional array whose rows can have different numbers of columns is called a/an ____________ array.
jagged array
When you use a typed collection you are taking advantage of the .NET Framework feature called ____________.
generics
When compared to untyped collections, typed collections reduce the number of ___________ errors.
runtime
The difference between a Queue and a Stack collection is that a Queue removes elements on a FIFO basis and a Stack removes them on a/an _____________ basis.
LIFO
Code the declaration for an array of ints named counts.
int[] counts = new int[]
Code a statement that creates an array of decimals named miles and assigns the values 27.2, 33.5, 12.8, and 56.4 to its elements.
decimal[] miles = {27.2, 33.5, 12.8, 56.4};
Given a one-dimensional array named yearlySalesTotals that contains decimal values, code the first line of a foreach statement that will let you access each element in the array in a variable named yearlySalesTotal.
foreach (dec yearlySalesTotal in yearlsSalesTotals)
Given an array named vendors, code a statement that sorts the elements of the array in alphabetical order.
Array.Sort(vendors);
Given a typed List collection of int values named dueDays, code a statement that adds the value 120 to the end of the array.
dueDays.Add(120);
You use the __________________ structure to represent dates and times.
DateTime
Given an empty StringBuilder object named cn, add this value to it: 2375.
cn.Append("2375");
The primary components of the .NET Framework are the .NET Framework Class Library and the

a. Command Language Runtime
b. Common Type Library
c. Managed Type Runtime
d. Common Language Runtime
d. Common Language Runtime
The .NET Framework Class Library consists of
a. solutions that are organized into sublibraries
b. solutions that are organized into namespaces
c. classes that are organized into sublibraries
d. classes that are organized into namespaces
d. classes that are organized into namespaces
Before a C# application can be run, it must be compiled into a language called
a. Microsoft Common Language
b. Microsoft Intermediate Language
c. Microsoft Runtime Language
d. Microsoft Solution Language
b. Microsoft Intermediate Language
To write the C# code for a form, you use a Visual Studio window called the
a. Form Designer
b. Solution Explorer
c. Toolbox
d. Code Editor
d. Code Editor
Two properties that are common to both forms and controls are the
a. Name and AcceptButton properties
b. Name and TabIndex properties
c. Name and Text properties
d. TabIndex and AcceptButton properties
c. Name and Text properties
The tab order determines the order in which
a. the tabs in the Form Designer window are displayed
b. the user must enter data into the controls on a form
c. the controls on a form receive focus when the user presses the Tab key
d. the controls are displayed on the form
c. the controls on a form receive focus when the user presses the Tab key
To create an access key that will move the focus to a text box, you
a. set the access key in the Text property of the text box
b. set the access key in the Text property of the label immediately before the text box
c. set the access key in the Text property of the label immediately after the text box
d. set the AccessKey property of the text box
a. set the access key in the Text property of the text box
When you run a form after you’ve used the Form Designer to design it but haven’t added any code to it,
a. the form is displayed but nothing works
b. the buttons don’t cause anything to happen, but otherwise the form works
c. the form can be compiled but not displayed
d. the form works, but none of the controls work
b. the buttons don’t cause anything to happen, but otherwise the form works
To refer to a property of an object in your C# code, you code the
a. class name followed by a period and the property name
b. property name followed by a period and the object name
c. object name followed by a period and the property name
d. property name followed by a period and the class name
c. object name followed by a period and the property name
What does the following code do?
txtMonthlyInvestment.Focus();
a. calls the Focus method of the current form instance
b. calls the Focus method of the txtMonthlyInvestment control
c. calls the txtMonthlyInvestment method of the Focus control
d. calls the () method of the txtMonthlyInvestment.Focus control
b. calls the Focus method of the txtMonthlyInvestment control
Which of the following is a valid comment?
a. This is a comment
b. ' This is a comment
c. / This is a comment
d. // This is a comment
d. // This is a comment
When you test an application, your goal is to
a. find runtime errors
b. fix runtime errors
c. find syntax errors
d. fix syntax errors
b. fix runtime errors
A data tip
a. gives advice on how to set property values
b. displays the value of a variable or property
c. displays the possible values for a property
d. indicates what data will be modified next
b. displays the value of a variable or property
One common cause of a runtime error is
a. a user entry that can’t be converted to a number
b. a control that has invalid property settings
c. a form that has invalid property settings
d. mispelled keywords in the C# code
b. a control that has invalid property settings
A constant stores data
a. that changes as a program executes
b. that does not change as a program executes
c. that does not need to be initialized
d. that is a reference type
b. that does not change as a program executes
Which of the following is a valid decimal literal?
a. 30.0
b. 30.0c
c. 30.0d
d. 30.0m
c. 30.0d
Variables named according to camel notation
a. capitalize the first letter of every word after the first word
b. use all lowercase letters
c. capitalize the first letter of every word including the first word
d. capitalize only the first letter of the variable name
a. capitalize the first letter of every word after the first word
decimal a = 2.5m;
decimal b = 4.0m;
decimal c = 12.7m;

int i = 4;
int j = 8;
int k = 17;

What is the value of x after the following statement is executed?
decimal x = Math.Round(c)
a. 0
b. 12
c. 12.7
d. 13
b. 12
Code Example 4-1

decimal a = 2.5m;
decimal b = 4.0m;
decimal c = 12.7m;

int i = 4;
int j = 8;
int k = 17;

What is the value of x after the following statement is executed?
int x = Math.pow(i, 2);
a. 0
b. 2
c. 4
d. 16
d. 16
Which statement is equivalent to the following statement?
total = total + tax;
a. total = tax++;
b. total += tax;
c. total = ++tax;
d. total =+ tax;
b. total += tax;
To override the order of precedence in an arithmetic expression, you can use
a. exclamation points
b. parentheses
c. square brackets
d. curled braces
b. parentheses
To concatenate two or more strings into one, you use this character:
a. #
b. |
c. &
d. +
d. +
What is the value of the cityState string after these statements are executed?
cityState = "Milwaukee";
cityState += ",";
cityState = "Wisconsin";
a. Milwaukee, Wisconsin
b. Milwaukee,Wisconsin
c. MilwaukeeWisconsin
d. Wisconsin
d. Wisconsin
A reference type stores
a. a data value
b. a reference to an object
c. a reference to a string
d. a reference to a class
b. a reference to an object
Assuming that a variable named sales contains a string that represents a valid decimal number, which of the following statements is valid code for converting the sales string to a decimal value?
a. decimal d = Parse.Decimal(sales);
b. decimal d = Decimal.Parse(sales);
c. decimal d = sales;
d. decimal d = Convert.Decimal(sales);
b. decimal d = Decimal.Parse(sales);
Assuming total is a decimal variable, which of the following statements does not convert it to a string?
a. string s = "Total: " + total;
b. string s = String.Parse(total);
c. string s = total.ToString();
d. string s = Convert.ToString(total);
a. string s = "Total: " + total;
If a decimal variable named total has a value of 1234.56, what string will result from the following statement?
string s = total.ToString("c2")
a. $1,234.56
b. 1,234.56
c. 1234.56
d. 1235
a. $1,234.56
Which of the following data types can’t be used for storing the number 123.4567?
a. double
b. int
c. decimal
d. single
b. int
A structure is
a. a reference type
b. a value type
c. a primitive type
d. a native type
b. a value type
Which of the following operators is not a relational operator?
a. =
b. !=
c. >
d. <=
a. =
Which of the following operators is not a logical operator?
a. !
b. |
c. >
d. &&
c. >
If you use a short-circuit logical operator to combine two expressions
a. both expressions are always evaluated
b. the second expression is evaluated only if it can affect the result
c. the first expression is evaluated only if it can affect the result
b. the second expression is evaluated only if it can affect the result
Which of the following statements is not true about if statements?
a. The statements within the braces of a clause have block scope.
b. An if statement can have an unlimited number of else if clauses.
c. Every if statement must include an else clause.
d. You can nest if statements within the if, else if, or else clauses of other if statements.
c. Every if statement must include an else clause.
Unlike an if-else statement, a switch statement
a. can’t test for a default condition
b. can’t be nested within another switch statement
c. can’t perform an operation based on the result of a boolean expression
b. can’t be nested within another switch statement
What must you do if you code an infinite loop in an application?
a. Use a counter variable to determine when the loop ends
b. Use a Boolean expression to determine when the loop ends
c. Code just a single statement within the loop
d. Cancel the application to end the loop
d. Cancel the application to end the loop
If you code a continue statement in a loop, it will cause the application
a. to jump to the beginning of the loop
b. to jump to the end of the loop
c. to enter break mode
d. to jump out of the loop
a. to jump to the beginning of the loop
When you’re in break mode, you can
a. press F5 to step through the program one statement at a time
b. press F11 to step through the program one statement at a time
c. use the Locals window to review the values of all of the variables that the program uses
d. use the Locals window to review the values of the variables used by the current statement and the four statements before and after it
b. press F11 to step through the program one statement at a time
The first expression that’s coded within the parentheses in a for loop
a. increments a counter variable
b. decrements a counter variable
c. assigns a starting value to a counter variable
d. tests a Boolean expression
c. assigns a starting value to a counter variable
In a while loop, the Boolean expression is tested
a. before the loop is executed
b. after the loop is executed
c. both before and after the loop is executed
a. before the loop is executed
What statement is used to implement the iteration structure?
a. if-else
b. while
c. switch
b. while
The signature of a method is formed by the
a. name of the method only
b. name of the method and its return type
c. name of the method and its parameter list
d. name of the method, its return type, and its parameter list
c. name of the method and its parameter list
If you declare a parameter for a method as optional,
a. the user must not provide a value for the parameter
b. the parameter must be assigned a constant value as its default
c. it must be declared before any required parameters
d. the value for the parameter must be passed by name
b. the parameter must be assigned a constant value as its default
Which of the following is not an advantage of passing arguments by name?
a. You don’t have to indicate if an optional parameter has been omitted
b. You don’t have to know the name of the associated parameter
c. You can pass some arguments by name even if other arguments are passed by position
d. You can pass the arguments in any order
b. You don’t have to know the name of the associated parameter
To generate an event handler for a control event, you can display the Events list for the control and then
a. select a name from the drop-down list for the event
b. click on the event
c. double-click on the event
d. right-click on the event and select the Generate Handler command
c. double-click on the event
If you have an int variable named yrs and two decimal variables named prin and rate, which statement can you use to call the method with the following method declaration?
private decimal GetInterest(int years,
decimal interestRate, decimal principle)
a. decimal interest = GetInterest(yrs, rate, prin);
b. decimal interest = GetInterest(rate, prin, yrs);
c. int interest = GetInterest(yrs, rate, prin);
d. int interest = GetInterest(rate, prin, yrs);
a. decimal interest = GetInterest(yrs, rate, prin);
Which of the following statements would you use to call a private method named InitializeVariables that accepts no parameters and doesn’t return a value?
a. InitializeVariables(void);
b. void InitializeVariables();
c. InitializeVariables();
d. void InitializeVariables(void);
b. void InitializeVariables();
Which of the following statements would you use to pass a variable named message by reference to a method named DisplayMessage?
a. DisplayMessage(reference message);
b. DisplayMessage(ref message);
c. DisplayMessage(message reference);
d. DisplayMessage(message ref);
e. DisplayMessage(message);
b. DisplayMessage(ref message);
Which of the following statements would be used to wire the Click event of a button named btnClear to an event handler named ClearControls?
a. this.btnClear.Click += System.EventHandler(this.ClearControls);
b. this.btnClear.Click += new System.EventHandler(this.ClearControls);
c. this.ClearControls += System.EventHandler(this.btnClear.Click);
d. this.ClearControls += new System.EventHandler(this.btnClear.Click);
b. this.btnClear.Click += new System.EventHandler(this.ClearControls);
Given a text box named txtNum, which of the following statements may cause a format exception?
a. string s = txtNum.Text;
b. if (txtNum.Text == null) newValue = 0;
c. if (txtNum.Text == "") newValue = 0;
d. decimal d = Convert.ToDecimal(txtNum.Text);
a. string s = txtNum.Text;
To display a dialog box, you can use the Show method of
a. the DialogBox class
b. a DialogBox object
c. the MessageBox class
d. a MessageBox object
c. the MessageBox class
Two properties of an object created from the Exception class are
a. Message and ToString
b. StackTrace and Name
c. Message and StackTrace
d. Message and Name
c. Message and StackTrace
In a try-catch statement, the finally block is executed
a. if an exception occurs in the try block
b. if an exception does not occur in the try block
c. if a catch block is executed
d. whether or not an exception occurs or a catch block is executed
d. whether or not an exception occurs or a catch block is executed
What statement causes a new exception to occur?
a. finally
b. catch
c. throw
d. try-catch
c. throw
When validating data entered into the text boxes of a form, it is not common to check whether
a. all required entries have been made
b. all text entries are non-numeric
c. all numeric entries can be converted to the appropriate data type
d. all numeric entries fall within a specified range
c. all numeric entries can be converted to the appropriate data type
An OverflowException can be avoided by a type of data validation known as
a. numeric checking
b. format checking
c. range checking
d. overflow checking
c. range checking
You may want to code generic methods for data validation because
a. they’re always more efficient
b. they allow you to reuse your data validation code
c. they’re the only way to perform range checking
d. they prevent all exceptions from being thrown
b. they allow you to reuse your data validation code
To determine the cause of an exception, you can
a. use the name of the exception class that’s displayed
b. use the error message that’s displayed
c. use the information in the stack trace
d. all of the above
d. all of the above
private void btnCalculate_Click(object sender, System.EventArgs e)
{
decimal weightInPounds = 0m;
try
{
weightInPounds = Convert.ToDecimal(txtPounds.Text);
if (weightInPounds > 0)
{
decimal weightInKilos = weightInPounds / 2.2m;
lblKilos.Text = weightInKilos.ToString("f2");
}
else
MessageBox.Show("Weight must be greater than 0.", "Entry error");
txtPounds.Focus();
}
catch(FormatException)
{
MessageBox.Show("Weight must be numeric.", "Entry error");
txtPounds.Focus();
}
}

If the user enters 118 in the text box and clicks the Calculate button, what does the code do?
a. It calculates the weight in kilograms.
b. It causes a runtime error.
c. It displays a dialog box with the message “Weight must be greater than 0.”
d. It displays a dialog box with the message “Weight must be numeric.”
a. It calculates the weight in kilograms.
When a statement within a try block causes an exception, the remaining statements in the try block
a. are executed after the statements in the catch block
b. are executed before the statements in the catch block
c. aren’t executed
c. aren’t executed
When you declare and initialize the values in an array, you are actually creating an instance of what class?
a. String
b. SortedList
c. ArrayList
d. Array
d. Array
To refer to the ninth element in a one-dimensional array named sales, you code
a. sales[8]
b. sales[9]
c. sales[10]
d. sales.Item(9)
a. sales[8]
To refer to the second column in the fourth row of a rectangular array named vendors, you code
a. vendors[3,1]
b. vendors[1,3]
c. vendors[4,2]
d. vendors[2,4]
a. vendors[3,1]
Which of the following statements determines the number of strings in the array that follows?
string[] customers = new string[55];
a. int size = customers.UpperBound;
b. int size = customers.Length;
c. int size = customers.Size();
d. int size = Arrays.Size(customers);
b. int size = customers.Length;
Which of the following method declarations is valid for a method that accepts an array of strings named customerNames?
a. private string[] ParseCustomerNames(customerNames){}
b. private void ParseCustomerNames(customerNames){}
c. private void ParseCustomerNames(customerNames string[]){}
d. private void ParseCustomerNames(string[] customerNames){}
d. private void ParseCustomerNames(string[] customerNames){}
You can use the BinarySearch method of the Array class to
a. search for a value in a sorted array and return the index of that value
b. search for a value in an unsorted array and return the index of that value
c. search for a value in a sorted array and return a bool value that indicates if that value was found
d. search for a value in an unsorted array and return a bool value that indicates if that value was found
a. search for a value in a sorted array and return the index of that value
A queue provides
a. an Item property for getting any item in the collection
b. an Add method for adding an item to the collection
c. a Remove method for removing an item from the collection
d. a Dequeue method for getting the next item in the collection
d. a Dequeue method for getting the next item in the collection
Which of the following is not true for typed collections?
a. Their classes can be found in the System.Collections.Generic namespace.
b. Trying to add the wrong type of data to one will cause a compile-time error.
c. You need to specify the data type of the collection when you declare it.
d. You need to cast any elements that are retrieved from the collection to the specified data type.
d. You need to cast any elements that are retrieved from the collection to the specified data type.
If a variable named date contains a valid DateTime value, which of the following statements checks if the date falls in a leap year?
a. bool isLeap = date.IsLeapYear;
b. bool isLeap = date.IsLeapYear();
c. bool isLeap = DateTime.IsLeapYear(date);
d. bool isLeap = DateTime.IsLeapYear(date.Year);
d. bool isLeap = DateTime.IsLeapYear(date.Year);
Which statement determines the due date for an invoice that is due 45 days after the invoice date?
a. DateTime dueDate = invoiceDate.Add(45);
b. DateTime dueDate = invoiceDate.AddDays(45);
c. DateTime dueDate = invoiceDate.Add(new TimeSpan(45));
d. DateTime dueDate = invoiceDate.Add(DateTime.DAYS, 45);
b. DateTime dueDate = invoiceDate.AddDays(45);
Which of the following statements refers to the second character in a String object named address?
a. char c = address(1);
b. char c = address(2);
c. char c = address[1];
d. char c = address[2];
c. char c = address[1];