|
|
|||||||||||||
by Jeff Friesen | |||||||||||||
| ||||||
How much do you know about generics? Based on your amount of generics knowledge, are you comfortable with having to maintain another developer's generified code, should your project manager tell you to do so? Perhaps you have not taken the time to determine how much you know about generics and how much you still have to learn. If you would like to assess your generics I.Q., you might find this article a helpful test of your generics knowledge.
Note: This article bases its content on a very useful and extensive generics FAQ that I discovered a couple of months ago. After you finish this article, do yourself a favor by checking out the FAQ, listed in the Resources section at the end of the article.
This section presents a test on several generics concepts. The test's 20 questions are a mixture of fill in the blank, true/false, multiple choice, and long answer. Take all the time you need to complete this test, but resist the urge to peek at the answers (which I present in the next section) until you finish. The test begins now.
Generics identifies language features for defining and using ________________ and ________________.
What is a parameterized type?
How does generics promote type safety?
Which of the following reference types cannot be generic?
True or false: Set<Object> is the supertype
of Set<String>.
What is a type parameter?
A ________________ describes a family of types and is used as a type parameter.
How is a concrete parameterized type different from a non-concrete parameterized type?
True or false: parameterized types have type parameters.
Which syntax would you use to express a wildcard with a lower
bound of some type?
?? extends type? super typeIdentify those types that cannot be used as type arguments.
Why can you not derive (directly or indirectly) generic classes
from Throwable?
What is type erasure?
Identify the tasks performed by type erasure.
True or false: The parameterized types List<Date>
and List<?> share the same runtime type.
The opposite of type erasure is known as ________________.
Which overloaded method is called by the following program?
// Overload.java
import java.util.Date;
public class Overload
{
public static void someOverloadedMethod (Object o)
{
System.out.println
("call to someOverloadedMethod(Object o)");
}
public static void someOverloadedMethod (Date d)
{
System.out.println
("call to someOverloadedMethod(Date d)");
}
public static <T> void methodCaller (T t)
{
someOverloadedMethod (t);
}
public static void main (String [] args)
{
methodCaller (new Date ());
}
}
What is an "unchecked" warning message?
When the compiler reports an unchecked or unsafe operation, it also tells you to recompile with the ________________ option to obtain details.
True or false: the code fragment System.out.println (o instanceof
Set<String>); will compile.
Pages: 1, 2 |
View all java.net Articles.
|
|