ISTM 250 Conceptual Exam #2 Boone Summer 2023

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

1/145

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:43 PM on 4/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

146 Terms

1
New cards

Exceptions are objects that are created from the _________________ class or one of its subclasses.

Exception

2
New cards

When compared to untyped collections, typed collections reduce:

the number of runtime errors and the amount of casting that's required

3
New cards

Which of the following is not true about the null-conditional operator?

It can only be used with reference types.

4
New cards

What is the value of the variable named s2 after the following statements are executed?

string s1 = "abcdefg";

string s2 = "";

for (int i = 0; i < s1.Length; i+=2)

{

s2 += s1[i];

}

aceg

5
New cards

To convert a StringBuilder object to a String, you can use:

the ToString() method of the StringBuilder object

6
New cards

What happens to radio buttons that are not placed in a group box?

They function as a separate group.

7
New cards

To cancel the FormClosing event of a form, you can:

set the Cancel property of the CancelEventArgs object to true

8
New cards

What keyword do you code at the beginning of a method if you only want it to be available within the current class?

private

9
New cards

What keyword do you code for the return type of a method that doesn't return any data

void

10
New cards

For each parameter in the parameter list for a method, you must code:

the data type of the parameter followed by the name of the parameter

11
New cards

When you call a method, the arguments you pass to it:

must be declared with data types that are compatible with the parameters

12
New cards

If you pass a variable by value, the called method:

can't change the value of the variable in the calling method

13
New cards

If you declare a parameter for a method is optional:

the parameter must be assigned a default value

14
New cards

To generate an event handler for a control event, you can display the Events list for the control and then:

double-click on the event

15
New cards

To generate a method call and a method from existing code, you can use a feature called:

refactoring

16
New cards

To define a tuple as the return type for a method, you define its members by separating them with commas and enclosing them in...

parentheses - ()

17
New cards

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)

decimal interest = GetInterest(yrs, rate, prin);

18
New cards

If the following GetInterest() method uses a decimal variable named interest to store the interest amount, which statement can you use to return the interest amount?

private decimal GetInterest(int years, decimal interestRate, decimal principle)

return interest;

19
New cards

Which of the following declares a private method named GetMessage() that returns a string value and requires a string parameter named fullName and a decimal parameter named currentBalance?

private string GetMessage(string fullName, decimal currentBalance)

20
New cards

Given a text box named txtNum, which of the following statements may cause a format exception?

decimal d = Convert.ToDecimal(txtNum.Text);

21
New cards

The list of methods that were called before an exception occurred is called the:

StackTrace

22
New cards

In a try-catch statement, the finally block is executed:

whether or not an exception occurs or a catch block is executed

23
New cards

When validating data entered into the text boxes of a form, it is not common to check whether:

all text entries are non-numeric

24
New cards

The code within a catch block is executed when:

the code in the try block throws an exception

25
New cards

Consider the code that follows. What does it do?

string value = "2";

try

{

int num = Convert.ToInt32(value);

}

MessageBox.Show("Valid integer");

catch(FormatException)

{

MessageBox.Show("Invalid integer");

}

The code doesn't compile

26
New cards

Consider the following code: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 "200#" in the text box and clicks the Calculate button, what does the code do?

It displays a dialog box with the message "Weight must be numeric."

27
New cards

Consider the following code: 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?

It calculates the weight in kilograms.

28
New cards

To refer to the ninth element in a one-dimensional array named sales, you code:

sales[8]

29
New cards

To refer to the second column in the fourth row of a rectangular array named vendors, you code:

vendors[3,1]

30
New cards

Which of the following statements 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.2m, 33.5m, 12.8m, 56.4m};

31
New cards

Which of the following for statements adds each element in a one-dimensional array named totals to a string named message?

for (int i = 0; i < totals.Length; i++) message += totals[i] + "|";

32
New cards

Which of the following is not true about collections?

Some collections use indexes that start with 1.

33
New cards

Which of the following is NOT true about a SortedList collection?

Key values must be added to a sorted list in alphabetical order.

34
New cards

A queue provides:

a Dequeue() method for getting the next item in the collection

35
New cards

Assuming the computer's regional settings are configured for the United States, which of the following statements creates a DateTime value whose date is set to March 28, 2021?

DateTime date = DateTime.Parse("03/28/2021");

36
New cards

Which of the following statements creates a DateTime value named dueDate that's set to the date December 31, 2021?

DateTime dueDate = new DateTime(2021, 12, 31);

37
New cards

Which property of the DateTime structure returns the current date with the time set to 12:00:00 AM?

Today

38
New cards

Which statement creates a DateTime value named invoiceDate that's set to the current date and time?

DateTime invoiceDate = DateTime.Now;

39
New cards

What is the value of startDate after the following statements are executed?

DateTime startDate = new DateTime(2021, 3, 1);

startDate = startDate.AddMonths(3);

June 1, 2021

40
New cards

What date is represented by d3 after these statements are executed?

DateTime d1 = new DateTime(2021, 3, 1);

DateTime d2 = new DateTime(2021, 3, 4);

TimeSpan t = d2.Subtract(d1);

DateTime d3 = d1.Add(t);

March 4, 2021

41
New cards

What method of the String class lets you format numbers, dates, and times?

Format()

42
New cards

What method can you use to remove spaces from the beginning and end of a string?

Trim()

43
New cards

Given the string variable that follows, which statement removes the spaces from the string and stores the result in the same string variable?

string lastName = " wilson ";

lastName = lastName.Trim();

44
New cards

Which of the following statements refers to the second character in a String object named address?

char c = address[1];

45
New cards

What is the value of the variable named s after the following statements are executed?

string fullName = "Miller, Edward";

int i = fullName.IndexOf(",");

string s = fullName.Substring(0, i);

Miller

46
New cards

What is the value of the variable named s after the following statements have been executed?

string fullName = "Miller, Edward";

int i = fullName.IndexOf(",");

string s = fullName.Substring(i + 1);

Edward

47
New cards

What is the value of the variable named s2 after the following statements have been executed?

string s1 = "The quick brown fox";

string[] words = s1.Split(' ');

string s2 = words[words.Length - 1];

fox

48
New cards

Given the following StringBuilder object named cn, which statement adds -9326 to it?

StringBuilder cn = new StringBuilder("2375-3847-8455");

cn.Append("-9326");

49
New cards

What is the value of the variable named s after the following statements are executed?

decimal d = 3892.22m;

string s = $"{d:##,##0.00;(##,##0.00)}";

3,892.22

50
New cards

What control do you use to create a group of radio buttons?

group box

51
New cards

What will the cboNumbers combo box contain if the following method is called twice?

private void Fill()

{

for (int i = 1; i < 5; i++)

{

cboNumbers.Items.Clear(); cboNumbers.Items.Add(i);

}

}

4

52
New cards

To change the name of a form, you can change the name of the form in the Solution Explorer and then:

let Visual Studio automatically change any other uses of the form name

53
New cards

You can use the Tag property of a form to get or set:

Any type of data

54
New cards

What will the following method return?

private string GetName(int customerID, bool readOnly)

A string

55
New cards

The signature of a method is formed by the:

name of the method and its parameter list

56
New cards

If you pass a variable by reference, the called method:

can change the value of the variable in the calling method

57
New cards

Which of the following code snippets passes an argument by name?

subtotal:subtotal

58
New cards

Which of the following is NOT an advantage of passing arguments by name?

You don't have to know the name of the associated parameter

59
New cards

Once you display the list of events for a control, you can wire an existing event handler to any event by:

selecting the event handler from the drop-down list for the event

60
New cards

When coding an expression-bodied method, what operator do you code after the method signature?

lambda operator (=>)

61
New cards

To delete an event handler, you not only have to delete its method but also its:

event wiring

62
New cards

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?

InitializeVariables();

63
New cards

Which of the following statements would you use to pass a variable named message by reference to a method named DisplayMessage?

DisplayMessage(ref message);

64
New cards

Which statement calls a method in the current form named SetButtons() and passes it a false value?

this.SetButtons(false);

65
New cards

Which of the following declares a method named GetMessage() that returns a string value and requires one decimal parameter named currentBalance and is only available within the current form?

private string GetMessage(decimal currentBalance)

66
New cards

Which of the following is a shorter way to code the following GetTotal() method?

private decimal GetTotal(decimal subtotal, decimal tax)

{

return subtotal + tax;

}

private decimal GetTotal(decimal subtotal, decimal tax) => subtotal + tax;

67
New cards

Which of the following declares a method named GetTotals() that returns a tuple that has two members named TotalQty and TotalAmt?

private (int TotalQty, decimal TotalAmt) GetTotals(int year) {}

68
New cards

Which of the following statements would be used to wire the Click event of a button named btnClear to an event handler named ClearControls()?

this.btnClear.Click += new System.EventHandler(this.ClearControls);

69
New cards

The process of checking user entries to make sure they're valid is called:

data validation

70
New cards

If a value that's assigned to an int variable is too large to be stored in it, what type of exception occurs?

OverflowException

71
New cards

If a text box entry can't be converted to a numeric data type, what type of exception occurs?

FormatException

72
New cards

To display a dialog box, you can use the Show() method of:

the MessageBox class

73
New cards

In a try-catch statement, a catch block for the Exception class can be used to catch:

any exceptions that aren't caught by previous catch blocks

74
New cards

Two properties of an object created from the Exception class are:

Message and StackTrace

75
New cards

When you catch an exception, which of its properties can you use to get a description of it?

Message

76
New cards

When you catch an exception, what method can you use to get the type of the exception?

GetType()

77
New cards

What statement causes an exception to occur?

to throw

78
New cards

You typically do NOT throw an exception:

when invalid data is detected

79
New cards

An OverflowException can be avoided by a type of data validation known as:

range checking

80
New cards

You may want to code generic methods for data validation because:

they allow you to reuse your data validation code

81
New cards

To determine the cause of an exception, you can:

all of the above

82
New cards

Which method of the Decimal class returns a false value if the entry can't be converted instead of throwing an exception?

TryParse()

83
New cards

Consider the following code:

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();

}

}

What type of data validation does this program do?

It displays a dialog box with the message "Weight must be numeric."

84
New cards

Consider the following code:

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 clicks the Calculate button without entering data in the text box, what does the code do?

It displays a dialog box with the message "Weight must be numeric."

85
New cards

Consider the following code:

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 -1 in the text box and clicks the Calculate button, what does the code do?

It displays a dialog box with the message "Weight must be greater than 0."

86
New cards

When a statement within a try block causes an exception, the remaining statements in the try block:

aren't executed

87
New cards

When you declare and initialize the values in an array, you are actually creating an instance of what class?

Array

88
New cards

Which of the following foreach statements adds each element in a one-dimensional array named totals to a string named message?

foreach (decimal total in totals) message += total + "|";

89
New cards

Which of the following statements declares a valid rectangular array?

string[,] js = new string[4,4];

90
New cards

Which of the following statements declares a valid jagged array?

string[ ][ ] js = new string[4][ ];

91
New cards

Which of the following statements gets the number of strings in the array that follows?

string[] customers = new string[55];

int size = customers.Length;

92
New cards

Which of the following method declarations is valid for a method that accepts an array of strings named customerNames?

private void ParseCustomerNames(string[] customerNames){}

93
New cards

Which of the following statements sorts a one-dimensional array named values?

Array.Sort(values);

94
New cards

You can use the BinarySearch() method of the Array class to:

search for a value in a sorted array and return the index of that value

95
New cards

Which .NET feature is used by typed collections but not by untyped collections?

Generics

96
New cards

Which of the following statements declares a typed List collection named dueDays that will hold int values?

List dueDays = new List();

97
New cards

Given a typed List collection of int values named dueDays, which of the following statements adds the value 120 to the end of the list?

dueDays.Add(120);

98
New cards

What is the value of kilos[1] after the code that follows is executed?

decimal[] kilos = {200, 100, 48, 59, 72};

for (int i = 0; i < kilos.Length; i++)

{

kilos[i] *= 2.2;

}

220.0

99
New cards

What is the value of lists after the statements that follow are executed?

string[,] names = new string[200,10];

int lists = names.GetLength(0);

200

100
New cards

What is the value of times[2,1] in the array that follows?

decimal[,] times = { {23.0, 3.5}, {22.4, 3.6}, {21.3, 3.7} };

3.7

Explore top flashcards

flashcards
Astronomy Science
63
Updated 934d ago
0.0(0)
flashcards
Fr. 4: Les Vêtements
35
Updated 1056d ago
0.0(0)
flashcards
PID Part 1
69
Updated 472d ago
0.0(0)
flashcards
AP Biology Unit 6
79
Updated 202d ago
0.0(0)
flashcards
ASD4 Cap 3
35
Updated 1154d ago
0.0(0)
flashcards
World History - Imperialism Test
53
Updated 1101d ago
0.0(0)
flashcards
Cerebellum
46
Updated 1032d ago
0.0(0)
flashcards
Astronomy Science
63
Updated 934d ago
0.0(0)
flashcards
Fr. 4: Les Vêtements
35
Updated 1056d ago
0.0(0)
flashcards
PID Part 1
69
Updated 472d ago
0.0(0)
flashcards
AP Biology Unit 6
79
Updated 202d ago
0.0(0)
flashcards
ASD4 Cap 3
35
Updated 1154d ago
0.0(0)
flashcards
World History - Imperialism Test
53
Updated 1101d ago
0.0(0)
flashcards
Cerebellum
46
Updated 1032d ago
0.0(0)