Generic Constructors QuizJ8 Home « Generic Constructors 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
6 questions
Lesson 3 - Generic InterfacesIn this lesson we look at generic interfaces and how to apply them in our Java code.Quiz3
6 questions
Lesson 4 - Generic ClassesThis lesson is about generic classes.Quiz4
6 questions
Lesson 5 - Bounded TypeIn this lesson on Java generics we investigate invariance and Bounded Type.Quiz5
7 questions
Lesson 6 - Unbounded Wildcard TypeIn this lesson we learn about generic Unbounded Wildcard Type.Quiz6
6 questions
Lesson 7 - Upper Bounded Wildcard TypeThis lesson on generics is about upper bounded wildcard types.Quiz7
6 questions
Lesson 8 - Lower Bounded Wildcard TypeThis lesson on generics is about lower bounded wildcard types.Quiz8
6 questions
Lesson 9 - Generic MethodsThis lesson is about generic methods.Quiz9
6 questions
Lesson 10 - Generic ConstructorsIn our final lesson on generics we look at generic constructors.This quiz.
8 questions

Generics Quiz 10

The quiz below tests your knowledge of the material learnt in Generics - Lesson 10 - Generic Constructors.

Question 1 : Is the following code snippet a valid example of a generic constructor?
public CubeNumber (T number) <T extends Number> { ... }
- When declaring a generic constructor in a non-generic class we have to declare the generic type BEFORE the constructor name so the code is invalid.
Question 2 : Is it possible to have generic constructors inside non-generic classes?
- It IS possible to have generic constructors inside non-generic classes.
Question 3 : The following code snippet is a valid example of a generic method?
public static <T extends Number> CubeNumber (T number) { ... }
- The code snippet is INVALID as the static keyword is not allowed in a contructor.
Question 4 : Generic constructors can be static or non-static?
- All constructors including generic ones instantiate objects and are therefore by defintion non-static.
Question 5 : When declaring a generic constructor in a non-generic class we have to declare the generic type before the constructor name?
- When declaring a generic constructor in a non-generic class we have to declare the generic type BEFORE the constructor name.
Question 6 : Is the following code snippet a valid example of a generic constructor?
public <T extends Number> CubeNumber (T number) { ... }
- The code snippet IS a valid example of a static generic method.
Quiz Progress Bar Please select an answer

What's Next?

That's it for the generic quizzes, the next set of quizzes are on streams.