Deck 20: Generics
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/22
Play
Full screen (f)
Deck 20: Generics
1
All generic method declarations have a type parameter section delimited by __________.
A) curly brackets ({ and })
B) angle brackets (< and >)
C) square brackets ([ and ] )
D) parenthesis
A) curly brackets ({ and })
B) angle brackets (< and >)
C) square brackets ([ and ] )
D) parenthesis
B
2
When the compiler encounters a method call,it attempts to locate a method declaration that has the same signature as the method call.
True
3
The ________ clause specifies the type constraint for type parameter T.
A) when
B) constraint
C) where
D) cnstr
A) when
B) constraint
C) where
D) cnstr
C
4
A generic method can be overloaded by ________ method.
A) a non-generic method
B) a generic method
C) a and b
D) None of the above
A) a non-generic method
B) a generic method
C) a and b
D) None of the above
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
5
Generic methods are often used to perform similar operations on different types of data.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
6
Generic methods can be overloaded by non-generic methods that have the same method name and the same or different number of method parameters.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
7
Generics provide __________ that allows the compiler to catch invalid types.
A) compile-time type safety
B) compile-time exception checking
C) compile-time error checking
D) run-time type safety
A) compile-time type safety
B) compile-time exception checking
C) compile-time error checking
D) run-time type safety
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
8
Generics make writing a program more __________.
A) elegant
B) cumbersome
C) concise
D) a and c
A) elegant
B) cumbersome
C) concise
D) a and c
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
9
You can use explicit type arguments to indicate the exact type that should be used to call a generic method (e.g.,< int >).
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
10
Type constraints restrict the type of the argument supplied to a particular type parameter.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
11
Which statement is false
A) Each type parameter list contains one or more type parameters, separated by commas.
B) A type parameter name must be unique among different generic methods.
C) The type parameters act as placeholders for the types of the arguments passed to a method.
D) The type parameter names throughout the method declaration must match those declared in the type parameter list.
A) Each type parameter list contains one or more type parameters, separated by commas.
B) A type parameter name must be unique among different generic methods.
C) The type parameters act as placeholders for the types of the arguments passed to a method.
D) The type parameter names throughout the method declaration must match those declared in the type parameter list.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
12
Generic methods can not be overloaded.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
13
When a method is called,the compiler tries to find a method that matches the _________ of the method call.
A) name
B) argument types
C) return type
D) a and b
E) All of the above
A) name
B) argument types
C) return type
D) a and b
E) All of the above
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
14
IComparable objects cannot,by default,be used with generic code.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
15
A type parameter _____________.
A) is an identifier that is used in place of an actual type name
B) can be used to declare the return type
C) acts as a placeholder for the type of an argument passed to the generic method
D) All of the above
A) is an identifier that is used in place of an actual type name
B) can be used to declare the return type
C) acts as a placeholder for the type of an argument passed to the generic method
D) All of the above
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
16
It's not possible to apply multiple constraints to a type parameter.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
17
__________ enable you to specify,with a single class declaration,a set of related classes.
A) Overloaded classes
B) Overriden classes
C) Generic classes
D) Generics
A) Overloaded classes
B) Overriden classes
C) Generic classes
D) Generics
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
18
A generic method's body is declared differently than that of any other method.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
19
A class can provide two or more generic methods that specify the same method name but with different number of method parameters and/or type parameters.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
20
If there's a constructor constraint,the type argument's class must not provide constructors.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
21
The type constraints determine the operations that can be performed on the type parameters.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
22
A ________ provides a means for describing a class in a type-independent manner.
A) subclass
B) generic class
C) concrete class
D) parameterized class
A) subclass
B) generic class
C) concrete class
D) parameterized class
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck