Deck 20: Generic Classes and Methods

ملء الشاشة (f)
exit full mode
سؤال
Which of the following statements is false?

A) Wildcard type arguments enable you to specify method parameters, return values, variables, and so on, that act as supertypes of parameterized types.
B) A wildcard-type argument is denoted by ?, which represents an "unknown type."
C) Because a wildcard is a type-parameter name, you can use it as a type name throughout a method's body.
D) If a wildcard is specified without an upper bound, then only the methods of type Object can be invoked on values of the wildcard type.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
One generic Stack class could be the basis for creating many Stack classes,

A) subclasses.
B) generic subclasses.
C) concrete classes.
D) parameterized classes.
E)g., Stack, Stack and Stack. These classes are known as __________.
سؤال
Which statement is false?

A) When declaring a generic method, the type parameter section is placed before the return type of the method.
B) Each type parameter section contains only one type parameter.
C) A type parameter is an identifier that specifies a generic type name.
D) Type parameters can represent only reference types.
سؤال
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.
سؤال
When compiling a generic class, the __________ option should be used to view the unchecked warning message.

A) -Xlint:unchecked.
B) -X:unchecked.
C) -warning:unchecked.
D) -unchecked.
سؤال
Generics provide __________ that allows programmers to catch invalid types at compile time.

A) compile-time type safety.
B) compile-time exception handling.
C) compile-time error checking.
D) run-time type safety.
سؤال
A wildcard type argument is denoted by a(n) __________.

A) asterisk (*).
B) underscore (_).
C) question mark (?).
D) caret (^).
سؤال
Suppose Stack is a generic class that has one type parameter. The assignment
Stack integerStack = new Stack(10);

A) is illegal.
B) is permitted and safe.
C) is permitted but unsafe, the compiler issues a warning message.
D) is permitted but unsafe, the runtime environment issues a warning message.
سؤال
__________ is the default upper bound of a type parameter.

A) String.
B) Comparable.
C) Class.
D) Object.
سؤال
When a generic class is instantiated without specifying a type argument, it is said to have a __________.

A) empty type.
B) raw type.
C) null type.
D) abstract type.
سؤال
When the compiler translates a generic method into Java bytecodes, it uses __________ to replace the type parameters with actual types.

A) erasure.
B) compile-time type replacement.
C) compile-time type checking.
D) compile-time type safety.
سؤال
__________ enable programmers to specify, with a single method declaration, a set of related methods.

A) Overloaded methods.
B) Overriden methods.
C) Generic methods.
D) Generics.
سؤال
Which statement is false?

A) A generic method may be overloaded.
B) A class can provide two or more generic methods that specify the same method name but different method parameters.
C) A generic method cannot be overloaded by non-generic methods.
D) When the compiler encounters a method call, it searches for the method declaration that most precisely matches the method name and the argument types specified in the call.
سؤال
Which of the following statements is true?

A) Overloaded methods are often used to perform similar operations on different types of data.
B) When the compiler encounters a method call, it attempts to locate a method declaration with a name and parameters that are compatible with the argument types in the method call.
C) Both a) and b) are true.
D) Neither a) nor b) is true.
سؤال
Class Number is ________ of both Integer and Double.

A) the subclass
B) composed
C) a descendent
D) the superclass
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/15
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 20: Generic Classes and Methods
1
Which of the following statements is false?

A) Wildcard type arguments enable you to specify method parameters, return values, variables, and so on, that act as supertypes of parameterized types.
B) A wildcard-type argument is denoted by ?, which represents an "unknown type."
C) Because a wildcard is a type-parameter name, you can use it as a type name throughout a method's body.
D) If a wildcard is specified without an upper bound, then only the methods of type Object can be invoked on values of the wildcard type.
C
2
One generic Stack class could be the basis for creating many Stack classes,

A) subclasses.
B) generic subclasses.
C) concrete classes.
D) parameterized classes.
E)g., Stack, Stack and Stack. These classes are known as __________.
D
3
Which statement is false?

A) When declaring a generic method, the type parameter section is placed before the return type of the method.
B) Each type parameter section contains only one type parameter.
C) A type parameter is an identifier that specifies a generic type name.
D) Type parameters can represent only reference types.
B
4
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
5
When compiling a generic class, the __________ option should be used to view the unchecked warning message.

A) -Xlint:unchecked.
B) -X:unchecked.
C) -warning:unchecked.
D) -unchecked.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
6
Generics provide __________ that allows programmers to catch invalid types at compile time.

A) compile-time type safety.
B) compile-time exception handling.
C) compile-time error checking.
D) run-time type safety.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
7
A wildcard type argument is denoted by a(n) __________.

A) asterisk (*).
B) underscore (_).
C) question mark (?).
D) caret (^).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
8
Suppose Stack is a generic class that has one type parameter. The assignment
Stack integerStack = new Stack(10);

A) is illegal.
B) is permitted and safe.
C) is permitted but unsafe, the compiler issues a warning message.
D) is permitted but unsafe, the runtime environment issues a warning message.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
9
__________ is the default upper bound of a type parameter.

A) String.
B) Comparable.
C) Class.
D) Object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
10
When a generic class is instantiated without specifying a type argument, it is said to have a __________.

A) empty type.
B) raw type.
C) null type.
D) abstract type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
11
When the compiler translates a generic method into Java bytecodes, it uses __________ to replace the type parameters with actual types.

A) erasure.
B) compile-time type replacement.
C) compile-time type checking.
D) compile-time type safety.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
12
__________ enable programmers to specify, with a single method declaration, a set of related methods.

A) Overloaded methods.
B) Overriden methods.
C) Generic methods.
D) Generics.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which statement is false?

A) A generic method may be overloaded.
B) A class can provide two or more generic methods that specify the same method name but different method parameters.
C) A generic method cannot be overloaded by non-generic methods.
D) When the compiler encounters a method call, it searches for the method declaration that most precisely matches the method name and the argument types specified in the call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which of the following statements is true?

A) Overloaded methods are often used to perform similar operations on different types of data.
B) When the compiler encounters a method call, it attempts to locate a method declaration with a name and parameters that are compatible with the argument types in the method call.
C) Both a) and b) are true.
D) Neither a) nor b) is true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
15
Class Number is ________ of both Integer and Double.

A) the subclass
B) composed
C) a descendent
D) the superclass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 15 في هذه المجموعة.