Professional Documents
Culture Documents
Section 1
1. A generic class is a type of class that associates one or more non-specific Java types with it. The
types are determined when an object of that class is created.
True or false?
True (*)
False
Correct
It allows you to create a generic method as you would an ordinary method, without specifying a
type between angle brackets. (*)
It is represented by the angle brackets <>. (*)
It is an extension of the Collections class that creates a list.
It is a keyword in Java that prints a diamond to the console screen.
None of the above.
3. Choose the instance where it would be preferable to use a collection without generics.
4. Collections are used with generics when you already know what type you will be collecting and you
are only collecting that one type.
True or false?
True
False (*)
True (*)
False
Correct
{1, 1, 2, 22, 305, 26} because a set may contain duplicates and all its elements are of the same
type.
{"Apple", 1, "Carrot", 2} because it records the index of the elements with following integers.
{1, 2, 5, 178, 259} because it contains no duplicates and all its elements are of the same type.
(*)
All of the above are sets because they are collections that can be made to fit any of the choices.
Correct
True (*)
False
Correct
Correct
Page 1 of 1