CORRECTLY LATEST UPDATE 2026
When you declare and initialize the values in an array, you are actually creating an
instance of what class? - Answers Array
To refer to the ninth element in a one-dimensional array named sales, you code -
Answers sales[8]
To refer to the second column in the fourth row of a rectangular array named vendors,
you code - Answers vendors[3,1]
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? - Answers decimal[ ]
miles = {27.2m, 33.5m, 12.8m, 56.4m};
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.Size; i++) message += totals[i] + "|";
for (int i = 0; i < totals.Length; i++) message += total + "|";
for (int i = 0; i < totals.Length; i++) message += totals[i] + "|";
for (int i = 1; i <= totals.Length; i++) message += total + "|"; - Answers for (int i = 0;
i < totals.Length; i++) message += totals[i] + "|";
Which of the following foreach statements adds each element in a one-dimensional
array named totals to a string named message?
foreach (total : totals) message += total + "|";
foreach (total in totals) message += total + "|";
foreach (decimal total : totals) message += total + "|";
foreach (decimal total in totals) message += total + "|"; - Answers foreach (decimal
total in totals) message += total + "|";
Which of the following statements declares a valid rectangular array?
string[,] js = new string[,];
string[,] js = new string[4,4];
string[ ][ ] js = new string[ ][ ];
string[ ][ ] js = new string[4][4]; - Answers B. string[,] js = new string[4,4];
Which of the following statements gets the number of strings in the array that
follows? string[ ] customers = new string[55];
int size = customers.UpperBound;
int size = customers.Length;
int size = customers.Size();
int size = Arrays.Size(customers); - Answers int size = customers.Length;
Which of the following method declarations is valid for a method that accepts an
array of strings named customerNames?
private string[] ParseCustomerNames(customerNames){}
private void ParseCustomerNames(customerNames){}
private void ParseCustomerNames(customerNames string[]){}
private void ParseCustomerNames(string[] customerNames){} - Answers private
void ParseCustomerNames(string[] customerNames){}
Which of the following statements sorts a one-dimensional array named values?
values = Array.Sort(values);
Array.Sort(values);
values = ArrayList.Sort(values);
, ArrayList.Sort(values); - Answers Array.Sort(values);
You can use the BinarySearch() method of the Array class to - Answers search for a
value in a sorted array and return the index of that value
Which .NET feature is used by typed collections but not by untyped collections? -
Answers Generics
When compared to untyped collections, typed collections reduce - Answers the
number of runtime errors and the amount of casting that's required
Which of the following is not true about collections?
Some collections use indexes that start with 1.
The capacity of a collection is adjusted automatically as new elements are added.
The items in all collections can be modified.
Collections can be used to store any type of object. - Answers Some collections use
indexes that start with 1.
Which of the following statements declares a typed List collection named dueDays
that will hold int values?
List dueDays = new List();
List<int> dueDays = new List<int>();
IntList dueDays = new IntList();
ArrayList dueDays = new ArrayList(); - Answers List<int> dueDays = new
List<int>();
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);
dueDays.Append(120);
dueDays.Insert(120);
dueDays.Insert(0, 120); - Answers dueDays.Add(120);
Which of the following is not true about a SortedList collection?
Key values must be added to a sorted list in alphabetical order.
You use the DictionaryEntry structure to work with an element of a sorted list.
You can use a key to get its associated value.
Each element in a sorted list consists of a key value and a related value. - Answers
Key values must be added to a sorted list in alphabetical order.
A queue provides:
an Item property for getting any item in the collection
an Add() method for adding an item to the collection
a Remove() method for removing an item from the collection
a Dequeue() method for getting the next item in the collection - Answers a Dequeue()
method for getting the next item in the collection
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;
} - Answers 220.0
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} }; - Answers 3.7
What is the value of lists after the statements that follow are executed?
string[,] names = new string[200,10];
int lists = names.GetLength(0); - Answers 200