Bounded Wildcard Types QuizJ8 Home « Bounded Wildcard Types Quiz

The questions in this quiz on Java are on the topics covered in the Generics section of the site. The table below lists the lesson used for each quiz, a description of the lesson content and the quiz number and questions associated with that lesson.

Lesson Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that quiz.

Click on a quiz in the table to go straight to the quiz for a particular lesson.

Generics Lessons Description Quiz Info.
Lesson 1 - Generic BasicsIn our first lesson on on generics we unravel the terminology behind java generics and look at some of the strange syntax we get when using it.Quiz1
7 questions
Lesson 2 - Raw/Generic Type ComparisonIn this lesson we compare raw and generic types to see the advantages of using generics.Quiz2
7 questions
Lesson 3 - Generic InterfacesIn this lesson we look at generic interfaces and how to apply them in our Java code.Quiz3
7 questions
Lesson 4 - Generic ClassesThis lesson is about generic classes.Quiz4
7 questions
Lesson 5 - Bounded TypesIn this lesson on java generics we investigate invariance and bounded types.Quiz5
7 questions
Lesson 6 - Unbounded Wildcard TypesIn this lesson we learn about generic unbounded wildcard types.Quiz6
7 questions
Lesson 7 - Bounded Wildcard TypesThis lesson on generics is about bounded wildcard types.This quiz.
8 questions
Lesson 8 - Generic MethodsThis lesson is about generic methods.Quiz8
7 questions
Lesson 9 - Generic ConstructorsIn for final lesson on generics we look at generic constructors.Quiz9
7 questions

Generics Quiz 7

The quiz below tests your knowledge of the material learnt in Generics - Lesson 7 - Bounded Wildcard Types.

Question 8 : What is the following code snippet an example of <T extends Number> ?
- <code>T extends Number</code> is an example of a <i>bounded type</em>.
Question 9 : We can use generics with any type?
- We can use generics with object types but not primitive types.
Question 10 : How are generics implemented?
- Generics are implemented by <i>erasure</em> (all generic code is removed at compile time) so legacy code can interoperate with generic code.
Question 11 : What is the following code snippet an example of <?> ?
- <code>?</code> is an example of an <i>unbounded wildcard type</em>.
Question 12 : Is the following code snippet valid? List<Object> aList = new ArrayList<String>();
- You may think the code snippet is valid as we know that <code>String</code> extends <code>Object</code> but this is not the case as generic types are <i>invariant</em>.
Question 13 : Is the following code snippet valid?

public class SimpleGenericInterfaceImpl implements SimpleGenericInterface<String> { ?
- The code snippet is valid as actual type specified for implementation, so class is not generic.
Question 14 : What is the following code snippet an example of <? extends Number> ?
- <code>? extends Number</code> is an example of a <i>bounded wildcard type</em>.
Quiz Progress Bar Please select an answer

What's Next?

In the next quiz we test your knowledge of generic methods.