Simple, Quality, Awesome Software

Making Generics Quiz

Below are the answers to the Making Generics Quiz, along with a brief discussion.

1. You use angle brackets by the class name: public class AmazingClass { /* ... */ }

2. False. Generic classes can have as many generic type parameters as you want. There is no (practical) limit on the number you can use.

3. True. Generic type constraints limit what types can be used to fill in the generic type parameter, but allow you to know more about the types being used, allowing you to do more with the generic type inside of the implementation.

4. True. This is the purpose of generic type constraints.