Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
15.10. Wildcards in Generics
This section
Practice test
12 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
4 cards from this lesson. Good the night before a test.
Try these first
- 1.
What does
<?>represent in generics?Hint
Think about flexibility in type.
- 2.
In the context of wildcards, what does 'extends' signify?
Hint
Consider when reading types.
- 3.
What wildcard allows any type?
- <?>
- <? extends T>
- <? super T>
Hint
Think about 'flexibility'.
- 4.
True or False: The syntax
<? extends Number>allows reading elements that are of type Number or its subtypes.- True
- False
Hint
Think about types of numbers.
- 5.
Write a method that accepts a list of any type using an unbounded wildcard and calculates the total number of items added to the list. How would you approach it?
Hint
Focus on the size of the list.
- 6.
Create a utility function that adds items of type
Tto a list that accepts upper bounded wildcards. Provide an example of its usage.Hint
Think of the method signature and its parameters carefully.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
2 more questions available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting