AllRounder.ai
Chapters in this course

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.

Enrol free

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 it
  • Whole chapter

    Revision test

    Mixed questions from across the chapter. Your answers get marked.

    Sign up to take it
  • Quick

    Flashcard drill

    4 cards from this lesson. Good the night before a test.

Try these first

  1. 1.

    What does <?> represent in generics?

    Hint

    Think about flexibility in type.

  2. 2.

    In the context of wildcards, what does 'extends' signify?

    Hint

    Consider when reading types.

  3. 3.

    What wildcard allows any type?

    • <?>
    • <? extends T>
    • <? super T>
    Hint

    Think about 'flexibility'.

  4. 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. 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. 6.

    Create a utility function that adds items of type T to 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 free

Quiz

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 free

Challenge 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