Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What is the syntax for an upper bound wildcard?
Look for the keyword 'extends'.
What kind of types can be used with a lower bound wildcard?
Think of what superclass means.
What does List<? extends Number> allow?
Think about the subclasses!
Can you add elements to a List defined as List<? extends Number>?
Consider how wildcards restrict adding elements.
Design a generic method that can accept a list of pets which are subclasses of a superclass, and also allow adding mammals to a list of animals.
Consider what types you want to allow and what you need to insert.
How would you refactor a method that uses non-bounded types into one that effectively uses bounded wildcards?
Identify where you need to read and write in your current implementation.
5 more questions in this section. Enroll free to practise them all.
Enroll free