Home > Articles > Programming > Java

  • Print
  • + Share This
Like this article? We recommend Exercises

Exercises

To reinforce your understanding of this series’ content , work through the following exercises. You'll find the answers in the code file that accompanies this article:

  • Define generics.
  • What Java version introduced generics?
  • Define generic type.
  • How do you syntactically express a generic type?
  • Identify four Java APIs that have been retrofitted to support generics.
  • Define type parameter, parameterized type, and actual type argument.
  • Identify the five kinds of actual type arguments supported by generics.
  • Define raw type. Why are raw types supported?
  • What is the rationale for using generics?
  • What is an unchecked warning message and how do you suppress it?
  • How do you specify a single upper bound for a type parameter? How do you specify multiple upper bounds?
  • Can you specify a lower bound for a type parameter? If so, how do specify the lower bound?
  • Define recursive type bound. Provide an example.
  • What is the scope of a type parameter?
  • State the fundamental rule of generic types and explain what this rule means.
  • How would you modify outputStack(Stack<Object> stack) so that you can output the contents of a Stack instance regardless of its element type?
  • Can you supply an upper or lower bound to the wildcard argument? If so, how do you accomplish this task?
  • Define generic method.
  • What happens when the compiler encounters an array-creation expression involving a type parameter or actual type argument?
  • Define reification. Are arrays reified? Are generic types reified?
  • Define erasure.
  • Why isn't it possible to specify array-creation expressions with type parameters or actual type arguments?
  • + Share This
  • 🔖 Save To Your Account