Deck 21: 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
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/35
Play
Full screen (f)
Deck 21: Collections
1
A _______ is one way to implement a dictionary
A) hash table
B) linked list
C) stack
D) queue
A) hash table
B) linked list
C) stack
D) queue
A
2
Prepackaged data-structure classes provided by theNET Framework are called ___________.
A) DS classes
B) data classes
C) collection classes
D) data structural classes
A) DS classes
B) data classes
C) collection classes
D) data structural classes
C
3
Enumerators can be used to modify the contents of collections.
False
enumerators cannot be used to modify the contents of collections,only to obtain the contents.
enumerators cannot be used to modify the contents of collections,only to obtain the contents.
4
All collection classes in theNET Framework implement some combination of collection interfaces.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
5
C# 6's using static directive ________.
A) converts each of a class's methods to static.
B) converts the class to static.
C) allows access to a class's static members without fully qualifying their names.
D) None of the above.
A) converts each of a class's methods to static.
B) converts the class to static.
C) allows access to a class's static members without fully qualifying their names.
D) None of the above.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
6
A _______ is the general term for a collection of key-value pairs.
A) book
B) glossary
C) dictionary
D) lexicon
A) book
B) glossary
C) dictionary
D) lexicon
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following is not a property of LinkedListNode
A) Value
B) Reference
C) Previous
D) Next
A) Value
B) Reference
C) Previous
D) Next
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
8
Enumerators must implement the IEnum interface.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
The generic class SortedDictionary takes two type arguments: the first is _______ and the second is ________.
A) the type of value, the type of key
B) the type of key, the type of value
C) the type of the lookup, the type of key
D) the type of value, the type of the lookup
A) the type of value, the type of key
B) the type of key, the type of value
C) the type of the lookup, the type of key
D) the type of value, the type of the lookup
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following is not a method provided by an array
A) Sort
B) Copy
C) BinarySearch
D) Reverse
E) None of the above
A) Sort
B) Copy
C) BinarySearch
D) Reverse
E) None of the above
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following is not a collection class in C#
A) ArrayList
B) HashTable
C) SortedDictionary
D) BitArray
E) None of the above
A) ArrayList
B) HashTable
C) SortedDictionary
D) BitArray
E) None of the above
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
12
All arrays implicitly inherit from which generic interface
A) IList
B) IEnumerable
C) IEnumerator
D) a and b
E) a and c
A) IList
B) IEnumerable
C) IEnumerator
D) a and b
E) a and c
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
13
Classes which implement the IEnumerator interface must contain which of the following methods
A)MoveNext
B)Reset
C)Current
D)Reverse
A) A, B, C
B) B, C, D
C) A, B, D
D) A, C, D
A)MoveNext
B)Reset
C)Current
D)Reverse
A) A, B, C
B) B, C, D
C) A, B, D
D) A, C, D
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following statements is false
A) Prior to C# 6, you could use a fully braced collection initializer to initialize a Dictionary's key-value pairs. For example, if you had a Dictionary< string, int > named toolInventory, you could create and initialize it as follows:
Var toolInventory = new Dictionary< string, int >{
{"Hammer", 13},
{"Saw", 17},
{"Screwdriver", 7}
};
A) is shorthand for creating the Dictionary then using its Add method to add each key-value pair.
B) The code in
C) C# 6's index initializers enable you to clearly indicate the key and the value in each key-value pair as follows:
Var toolInventory = new Dictionary< string, int >{
["Hammer"] = 13,
["Saw"] = 17,
["Screwdriver"] = 7
};
D) Prior to C# 6, any collection that defined an Add extension method could be initialized with a collection initializer. As of C# 6, the compiler also supports collection initializers for any collection that has an Add instance method.
A) Prior to C# 6, you could use a fully braced collection initializer to initialize a Dictionary's key-value pairs. For example, if you had a Dictionary< string, int > named toolInventory, you could create and initialize it as follows:
Var toolInventory = new Dictionary< string, int >{
{"Hammer", 13},
{"Saw", 17},
{"Screwdriver", 7}
};
A) is shorthand for creating the Dictionary then using its Add method to add each key-value pair.
B) The code in
C) C# 6's index initializers enable you to clearly indicate the key and the value in each key-value pair as follows:
Var toolInventory = new Dictionary< string, int >{
["Hammer"] = 13,
["Saw"] = 17,
["Screwdriver"] = 7
};
D) Prior to C# 6, any collection that defined an Add extension method could be initialized with a collection initializer. As of C# 6, the compiler also supports collection initializers for any collection that has an Add instance method.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
15
foreach is associated with only the IEnumerator interface.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
16
Storing everything as objects in a collection will provide a performance boost.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
17
One should use the collections from the ________ namespace to help specify the exact type that will be stored in a collection.
A) System.Collections
B) System.Collections.Generics
C) System.Collections.Specialized
D) None of the above
A) System.Collections
B) System.Collections.Generics
C) System.Collections.Specialized
D) None of the above
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following statements is false
A) The LinkedList class is a singly linked list.
B) The LinkedList class's enumerator loops over the values of the nodes, not the nodes themselves.
C) One LinkedListNode cannot be a member of more than one LinkedList.
D) Method Find performs a linear search on the list and returns the first node that contains a value equal to the passed argument.
A) The LinkedList class is a singly linked list.
B) The LinkedList class's enumerator loops over the values of the nodes, not the nodes themselves.
C) One LinkedListNode cannot be a member of more than one LinkedList.
D) Method Find performs a linear search on the list and returns the first node that contains a value equal to the passed argument.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
19
All arrays implicitly inherit from abstract base class Collection.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
20
Using the collection classes,___________.
A) programmers can code faster
B) programmers can expect excellent performance and maximum execution speed
C) the program uses memory efficiently
D) All of the above
A) programmers can code faster
B) programmers can expect excellent performance and maximum execution speed
C) the program uses memory efficiently
D) All of the above
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
21
Covariance works only with reference types that are related by a class hierarchy.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following statements about functional programming is false
A) You do not need to specify how to iterate through the elements or declare and use any mutable (that is, modifiable) variables. This is known as internal iteration, because the library code (behind the scenes) iterates through all the elements to perform the task.
B) A key aspect of functional programming is immutability-not modifying the data source being processed or any other program state, such as counter-control variables in loops. This eliminates common errors that are caused by modifying data incorrectly.
C) A filter operation combines the elements of a collection into a single new value, typically using a lambda that specifies how to combine the elements.
D) A map operation results in a new collection in which each element of the original collection is mapped to a new value (possibly of a different type). The new collection has the same number of elements as the collection that was mapped.
A) You do not need to specify how to iterate through the elements or declare and use any mutable (that is, modifiable) variables. This is known as internal iteration, because the library code (behind the scenes) iterates through all the elements to perform the task.
B) A key aspect of functional programming is immutability-not modifying the data source being processed or any other program state, such as counter-control variables in loops. This eliminates common errors that are caused by modifying data incorrectly.
C) A filter operation combines the elements of a collection into a single new value, typically using a lambda that specifies how to combine the elements.
D) A map operation results in a new collection in which each element of the original collection is mapped to a new value (possibly of a different type). The new collection has the same number of elements as the collection that was mapped.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
23
Using a cast operator to assign an array of base-class-type elements to an array of derived-class-type elements is an example of contravariance.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
24
Assigning an array of a derived-class type to an array variable of a base-class type is an example of contravariance.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
25
In functional programming,you specify ________ you want to accomplish in a task,but not ________ to accomplish it.
A) how, what
B) when, how
C) what, when
D) what, how
A) how, what
B) when, how
C) what, when
D) what, how
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
26
When specifying a lambda parameter's type and/or when a lambda has more than one parameter,you must enclose the parameter list in ________.
A) ( )
B) [ ]
C) < >
D) " "
A) ( )
B) [ ]
C) < >
D) " "
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
27
The compiler converts LINQ queries into calls to ________,many of which have delegate parameters.
A) instance methods
B) constructors
C) extension methods
D) void methods
A) instance methods
B) constructors
C) extension methods
D) void methods
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
28
Class Enumerable provides static method ________ to produce an IEnumerable< int > containing integer values in sequence.The first argument specifies the starting value and the second specifies the number of values to produce.
A) Span
B) Sequence
C) Spread
D) Range
A) Span
B) Sequence
C) Spread
D) Range
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following statements is false
A) Lambda expressions allow you to define simple, anonymous methods.
B) A lambda's return type is listed to the left of the lambda.
C) A delegate can hold a reference to a lambda expression that has a signature that's compatible with the delegate type.
D) A lambda expression is called via a variable that references it.
A) Lambda expressions allow you to define simple, anonymous methods.
B) A lambda's return type is listed to the left of the lambda.
C) A delegate can hold a reference to a lambda expression that has a signature that's compatible with the delegate type.
D) A lambda expression is called via a variable that references it.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following statements is false
A) A concept called threads enables the operating system to run parts of an app concurrently. Though all of these tasks can make progress concurrently, they may do so by sharing one processor core.
B) With multicore processors, apps can operate truly in parallel on separate cores, possibly increasing the app's performance substantially.
C) Parallelizing apps and algorithms to take advantage of multiple cores is difficult and highly error prone, especially if those tasks share data that can be modified by one or more of the tasks.
D) A benefit of functional programming is that you can easily ask the library to perform a task with parallel processing to take advantage of a processor's multiple cores. This is the purpose of CLINQ (Concurrent LINQ)-an implementation of the LINQ to Objects extension methods that parallelizes the operations for increased performance.
A) A concept called threads enables the operating system to run parts of an app concurrently. Though all of these tasks can make progress concurrently, they may do so by sharing one processor core.
B) With multicore processors, apps can operate truly in parallel on separate cores, possibly increasing the app's performance substantially.
C) Parallelizing apps and algorithms to take advantage of multiple cores is difficult and highly error prone, especially if those tasks share data that can be modified by one or more of the tasks.
D) A benefit of functional programming is that you can easily ask the library to perform a task with parallel processing to take advantage of a processor's multiple cores. This is the purpose of CLINQ (Concurrent LINQ)-an implementation of the LINQ to Objects extension methods that parallelizes the operations for increased performance.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following statements is false
A) A delegate variable can hold a reference to any method.
B) The real power of delegates is in passing method references as arguments to methods.
C) A method name can be passed directly to a delegate parameter, rather than first assigning it to a delegate variable.
D) A delegate type is declared by preceding a method header with keyword delegate (placed after any access specifiers, such as public or private) and following the method header with a semicolon.
A) A delegate variable can hold a reference to any method.
B) The real power of delegates is in passing method references as arguments to methods.
C) A method name can be passed directly to a delegate parameter, rather than first assigning it to a delegate variable.
D) A delegate type is declared by preceding a method header with keyword delegate (placed after any access specifiers, such as public or private) and following the method header with a semicolon.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following statements is false
A) You filter elements to produce a collection of results that match a condition-known as a predicate.
B) LINQ extension method Where receives as its argument a Func delegate for a method that receives one argument and returns a bool indicating whether a given element should be included in the collection returned by Where.
C) The OrderBy extension method receives as its argument a Func delegate representing a method that receives one parameter (an element in the collection) and returns a value that's used to order the results.
D) Calls to Where and OrderBy are tuned to execute immediately at high performance.
A) You filter elements to produce a collection of results that match a condition-known as a predicate.
B) LINQ extension method Where receives as its argument a Func delegate for a method that receives one argument and returns a bool indicating whether a given element should be included in the collection returned by Where.
C) The OrderBy extension method receives as its argument a Func delegate representing a method that receives one parameter (an element in the collection) and returns a value that's used to order the results.
D) Calls to Where and OrderBy are tuned to execute immediately at high performance.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following statements is false
A) A delegate is an object that holds a reference to a method.
B) Via delegates, you can assign methods to variables, and pass methods to and from other methods.
C) You can call methods through variables of delegate types.
D) All of the above statements are true.
A) A delegate is an object that holds a reference to a method.
B) Via delegates, you can assign methods to variables, and pass methods to and from other methods.
C) You can call methods through variables of delegate types.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
34
To initiate parallel processing,invoke IEnumerable< T > extension method ________ (from class ParallelEnumerable),which returns a ParallelQuery< T >.
A) Parallel
B) AsConcurrent
C) AsParallel
D) Concurrent
A) Parallel
B) AsConcurrent
C) AsParallel
D) Concurrent
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
35
A lambda expression begins with a parameter list and is followed by the ________ lambda operator and an expression that represents the lambda's body.
A) - >
B) = >
C) :^)
D) =)
A) - >
B) = >
C) :^)
D) =)
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck