Generics
- What is use of wildcards?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The wildcard can be used in a variety of situations: as the type of a parameter, field, or local variable; sometimes as a return type (though it is better programming practice to be more specific). The wildcard is never used as a type argument for a generic method invocation, a generic class instance creation, or a supertype.
- Which of these keywords is used to upper bound a wildcard?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
extends
- Which of these is an correct way making a list that is upper bounded by class Number?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
List extends Number>
- Which of the following keywords are used for lower bounding a wild card?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
A lower bounded wildcard is expressed using the wildcard character (‘?’), following by the super keyword, followed by its lower bound.