Deck 8: Advanced Collections
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/74
Play
Full screen (f)
Deck 8: Advanced Collections
1
With a two dimensional array, when the number of columns in the rows differs, a jagged array can be created.
True
2
In C#, a two-dimensional array is usually visualized as a table divided into columns and rows where data is stored in contiguous memory locations by column.
False
3
The Queue class represents a Last In First Out (LIFO) collection of objects while the Stack collection class represents a simple FIFO (First In First Out) collection.
False
4
C# uses a row major format for accessing arrays, which means that the elements are printed in rows. Every entry in the first column is printed before moving to the second column.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
5
With C#, you are limited to 10 dimensions for multi-dimensional arrays.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
6
The string class stores an immutable series of characters--meaning once you assign a string reference a value, that referenced location's value cannot be modified.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
7
The GetLength( ) method can be called to return the number of rows or columns.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
8
The Length property can be used to return the total number of elements in all dimensions.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
9
The major requirement of dealing with multi-dimensional arrays is the fact that all data values placed in an array must be of the same base type.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
10
For a declaration such as, int [ , ] anArray = new int [6, 5], a total of 11 memory locations can be accessed using the identifier anArray.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
11
double [ , ] price = new double [2 , 5] {{1.1, 1.2, 1.3, 1.5, 1.4}{2.1, 2.2, 2.3, 2.5, 2.4}};
With the declaration above, price[0,2] refers to 2.2.
With the declaration above, price[0,2] refers to 2.2.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
12
The Rank property is used with array collections to return the number of dimensions.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
13
The string is a reference type in C#.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
14
Console.WriteLine(calories.GetUpperBound(0)); returns the largest value in an array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
15
double [ , ] price = new double [2 , 5] {{1.1, 1.2, 1.3, 1.5, 1.4}{2.1, 2.2, 2.3, 2.5, 2.4}};
Looking above, the value of price.Length is 10.
Looking above, the value of price.Length is 10.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
16
In C#, you may access a two-dimensional array element using the notation [ , ] or through using a double set of braces ([ ] [ ]).
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
17
double [ , ] price = new double [2 , 5] {{1.1, 1.2, 1.3, 1.5, 1.4}{2.1, 2.2, 2.3, 2.5, 2.4}};
With the declaration above, price[1] refers to 1.2.
With the declaration above, price[1] refers to 1.2.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
18
Collection classes are classes that enable you to store and retrieve various groups of objects.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
19
The foreach loop structure cannot be used to iterate through a multi-dimensional array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
20
Multi-dimensional array identifiers are normally defined using a plural noun.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following would define a two dimensional structure to store temperature during three periods of a day for seven days?
A) int [ , ] temp = new int [7, 3];
B) int [ , ] temp = new int [6, 2];
C) int temp[7] [3 ] = new temp [7] [3];
D) int temp[6] [2 ] = new temp [6] [2];
A) int [ , ] temp = new int [7, 3];
B) int [ , ] temp = new int [6, 2];
C) int temp[7] [3 ] = new temp [7] [3];
D) int temp[6] [2 ] = new temp [6] [2];
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
22
Since the string data type is a reference type, you compare addresses as opposed to comparing contents or values when you use the equality operators with two string data items.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
23
C# has two types of string literals. Quoted string literals appear between double quotation marks (" ") and verbatim string literal, which start with the at symbol (@).
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
24
Normally you will want to use two integral values to reference individual elements in a two-dimensional array. If you use just one integral value, you get all of the values for that row.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
25
The string type allows individual characters to be accessed using an index with [ ].
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
26
With a two-dimensional array, GetLength(0) returns the number of rows and GetLength(1) returns the number of columns in the array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following could be a method heading for a member method that returns a two-dimensional array?
A) int [ , ] void DoSomething( )
B) void int [ , ] DoSomething( )
C) int [ , ] DoSomething( )
D) void DoSomething[ , ]
A) int [ , ] void DoSomething( )
B) void int [ , ] DoSomething( )
C) int [ , ] DoSomething( )
D) void DoSomething[ , ]
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
28
There are several ways to do a compile-time initialization of two-dimensional arrays. All of the following are valid ways EXCEPT ____.
A) int [, ] anArray = {{100, 100, 100} {100, 100, 100}};
B) int [ , ] anArray = new int [ , ] {{100, 100, 100} {100, 100, 100}};
C) int [ , ] anArray = new int [2, 3 ] {{100, 100, 100} {100, 100, 100}};
D) int [ ] anArray = new int [10 ] {{100, 100, 100} {100, 100, 100}};
A) int [, ] anArray = {{100, 100, 100} {100, 100, 100}};
B) int [ , ] anArray = new int [ , ] {{100, 100, 100} {100, 100, 100}};
C) int [ , ] anArray = new int [2, 3 ] {{100, 100, 100} {100, 100, 100}};
D) int [ ] anArray = new int [10 ] {{100, 100, 100} {100, 100, 100}};
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
29
The ArrayList class can be used to create a listlike structure that can dynamically increase or decrease in length.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
30
A two dimensional array is accessed much like you access cells in a spreadsheet.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
31
The ArrayList does not allow you to mix types. All elements must be of the same data type.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
32
A Hashtable represents a collection of key/value pairs that are organized based on the hash code of the key.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
33
If an array named num is dimensioned to hold 10 values in 5 rows and 2 columns, how would you store 50 in the first physical row and first physical column?
A) num[ 1, 1 ] = 50;
B) num[ 0 , 0 ] = 50;
C) num = 50 [ ] ;
D) num5 = 50;
A) num[ 1, 1 ] = 50;
B) num[ 0 , 0 ] = 50;
C) num = 50 [ ] ;
D) num5 = 50;
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
34
The ArrayList class requires you to add and remove elements to/from the structure using Push( ) and Pop( ) methods.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
35
One of the special properties in the ArrayList class is Count. It returns ____.
A) an int representing the number of values currently stored in the array
B) an int representing the size the array was dimensioned
C) how much storage is consumed by the entire array
D) the length of an individual element of the array
A) an int representing the number of values currently stored in the array
B) an int representing the size the array was dimensioned
C) how much storage is consumed by the entire array
D) the length of an individual element of the array
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following is a valid example of calling a method and sending it a two-dimensional array argument?
A) DisplayArrayContents(int [ , ] anArray);
B) DisplayArrayContents(anArray);
C) DisplayArrayContents(anArray[10, 2]);
D) DisplayArrayContents(int [10, 2] anArray);
A) DisplayArrayContents(int [ , ] anArray);
B) DisplayArrayContents(anArray);
C) DisplayArrayContents(anArray[10, 2]);
D) DisplayArrayContents(int [10, 2] anArray);
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
37
One of the properties of the ArrayList class is ____. It Gets or sets the number of elements that the ArrayList can contain.
A) Length
B) Capacity
C) Rank
D) Count
A) Length
B) Capacity
C) Rank
D) Count
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following is a valid heading for a method that could accept the two-dimensional array as an argument?
A) void DisplayOutput(double [ , ] anArray)
B) void DisplayOutput(double [10 , 2 ] anArray)
C) void DisplayOutput(double anArray)
D) void DisplayOutput(double anArray [10 , 2])
A) void DisplayOutput(double [ , ] anArray)
B) void DisplayOutput(double [10 , 2 ] anArray)
C) void DisplayOutput(double anArray)
D) void DisplayOutput(double anArray [10 , 2])
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
39
BinarySearch( ) is ____.
A) a method in the ArrayList class
B) an instance method
C) usable with floating point type arrays
D) a method in the string class
A) a method in the ArrayList class
B) an instance method
C) usable with floating point type arrays
D) a method in the string class
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
40
int [ , ] score = {{88, 66, 76, 92, 95} {67, 88, 45, 99, 80}}; int total = 0;
Foreach (int val in score)
Total += val;
Using the code shown above, what is added to total during the first iteration?
A) 0
B) 88
C) 86, 66, 76, 92 and 95
D) unknown, because val is not initialized
Foreach (int val in score)
Total += val;
Using the code shown above, what is added to total during the first iteration?
A) 0
B) 88
C) 86, 66, 76, 92 and 95
D) unknown, because val is not initialized
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following returns the number of columns in a two-dimensional array?
A) Rank
B) GetLength(0)
C) GetLength(1)
D) GetLength
A) Rank
B) GetLength(0)
C) GetLength(1)
D) GetLength
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
42
string [ , ] name = new string [2, 3] {{"Alex", "Ben", "Cay"}, {"Jose", "Tyne", "Yin" }};
Looking above, what does name[0, 1] reference?
A) l
B) Ben
C) Alex
D) Al
Looking above, what does name[0, 1] reference?
A) l
B) Ben
C) Alex
D) Al
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
43
The ____ method adds an object to the end of the queue.
A) Enqueue( )
B) Dequeue( )
C) Pop( )
D) Push( )
A) Enqueue( )
B) Dequeue( )
C) Pop( )
D) Push( )
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
44
The method that deletes a number of characters beginning at a specified position is ____.
A) Remove( )
B) Delete( )
C) Replace( )
D) ReplaceAt( )
A) Remove( )
B) Delete( )
C) Replace( )
D) ReplaceAt( )
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
45
int [ , , ] anArray = new [3, 2, 7] allows ____ elements to be stored.
A) 42
B) 12
C) 7
D) 3
A) 42
B) 12
C) 7
D) 3
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
46
string sValue = "Life is about choices";
String [ ] sn = sValue.Split(' ');
After the above segment of code is executed, where is "choices" stored?
A) sn[0]
B) sn[4]
C) sn[3]
D) sValue
String [ ] sn = sValue.Split(' ');
After the above segment of code is executed, where is "choices" stored?
A) sn[0]
B) sn[4]
C) sn[3]
D) sValue
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
47
For a two-dimensional array, values are stored ____________ using a row major format.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
48
In order to determine the position of one or more characters inside a string argument, use the ____ method of the string class.
A) Location( )
B) Position ( )
C) IndexOf( )
D) Place( )
A) Location( )
B) Position ( )
C) IndexOf( )
D) Place( )
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
49
Which of the following segments of code will display the first row of a two dimensional array?
A) for (int i = 0; i Console.Write(anArray[0, i] + "\t");
B) for (int i = 0; i Console.Write(anArray[0, i] + "\t");
C) for (int i = 0; i Console.Write(anArray[i, 0] + "\t");
D) for (int i = 0; i Console.Write(anArray[i, 0] + "\t");
A) for (int i = 0; i Console.Write(anArray[0, i] + "\t");
B) for (int i = 0; i Console.Write(anArray[0, i] + "\t");
C) for (int i = 0; i Console.Write(anArray[i, 0] + "\t");
D) for (int i = 0; i Console.Write(anArray[i, 0] + "\t");
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
50
C# has two types of string literals. The @-quoted string literals are called ____.
A) quoted string literal
B) at string literal
C) actual string literal
D) verbatim string literal
A) quoted string literal
B) at string literal
C) actual string literal
D) verbatim string literal
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
51
____ are types of data structures that consist of a sequence of data records such that in each record there is an additional field that contains a reference (i.e., a link) to the next record in the sequence.
A) Arrays
B) ArrayLists
C) Linked lists
D) Strings
A) Arrays
B) ArrayLists
C) Linked lists
D) Strings
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
52
Which of the following is an example of a collection class?
A) Array
B) Queue
C) HashTable
D) all of the above
A) Array
B) Queue
C) HashTable
D) all of the above
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
53
Which method in the string class might be useful to create a table with values number aligned?
A) Align( )
B) Concat( )
C) PadLeft( )
D) Split( )
A) Align( )
B) Concat( )
C) PadLeft( )
D) Split( )
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
54
Which class represents a First-In-First-Out (FIFO) collection, which is useful for storing objects in the order they were received for sequential processing?
A) Queue
B) HashTable
C) Stack
D) ArrayList
A) Queue
B) HashTable
C) Stack
D) ArrayList
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
55
Console.Write("AnExample".PadLeft(20, "#") returns ____.
A) ###########AnExample
B) AnExample###########
C) AnExample
D) AnExample
A) ###########AnExample
B) AnExample###########
C) AnExample
D) AnExample
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
56
The method ____ of the ArrayList class returns an arraylist that is a subset of another arraylist.
A) GetSubList( )
B) InsertRange( )
C) SubList( )
D) GetRange( )
A) GetSubList( )
B) InsertRange( )
C) SubList( )
D) GetRange( )
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
57
Console.Write("anExample".IndexOf("a")); returns ____.
A) null
B) 4
C) 04
D) 0
A) null
B) 4
C) 04
D) 0
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
58
string sValue = "Life is about choices";
String [ ] sn = sValue.Split(' ');
Using the Substring( ) method with sValue, which of the following references the word choices?
A) sValue.Substring(14, 7);
B) sValue.Substring(3);
C) sValue.Substring("choices");
D) sValue.Substring(15, 7);
String [ ] sn = sValue.Split(' ');
Using the Substring( ) method with sValue, which of the following references the word choices?
A) sValue.Substring(14, 7);
B) sValue.Substring(3);
C) sValue.Substring("choices");
D) sValue.Substring(15, 7);
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
59
The string method that retrieves part of a string from a string argument is ____.
A) Trim( )
B) Substring( )
C) Retrieve( )
D) IndexOf( )
A) Trim( )
B) Substring( )
C) Retrieve( )
D) IndexOf( )
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
60
The method in the string class that returns the string in uppercase is ____.
A) StringUpper( )
B) Upper( )
C) ConvertToUpper( )
D) ToUpper( )
A) StringUpper( )
B) Upper( )
C) ConvertToUpper( )
D) ToUpper( )
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
61
The major requirement when working with arrays is the fact that all data values placed in an array must be of the ____________.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
62
If you override the GetHashCode( ) method, you must also override the ____________ method to guarantee that two objects considered equal have the same hash code. Both are inherited from the object class.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
63
C# is a row major language, which means you specify the column index ____________ when you reference elements in a two-dimensional array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
64
Strings are considered ____________ because once you give a string a value; it cannot be modified. Methods that seem to be modifying a string are actually returning a new string containing the modification.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
65
C# also includes a generic ____________ class that is very similar to the ArrayList class. The primary difference between the two classes is that objects do not have to be the same type when they are pushed on an ArrayList, unlike the other class, which requires all objects to be of the same type..
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
66
As with the ArrayList class, in order to instantiate objects of many of the collection classes, you need to include a using ____________.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
67
Like traditional arrays, indexes of ArrayList objects are ____________.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
68
____________ class represents a simple last-in-first-out (LIFO) collection of objects.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
69
The property ____________ returns the number of dimensions of the array.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
70
In C#, the string type allows individual characters to be accessed using a(n) ____________ with the [ ].
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
71
The ____________ are defined to compare the contents of strings instead of comparing their addresses.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
72
The ____________ property can be used with multidimensional arrays to get the total number of elements in all dimensions.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
73
The ____________ method is used with the ArrayList class to push items on the list.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck
74
To declare a three-dimensional array, three integral values are used. The first number specifies the number of ____________.
Unlock Deck
Unlock for access to all 74 flashcards in this deck.
Unlock Deck
k this deck