What is the purpose of the `? super T` wildcard in Java generics?
A. It restricts the use of the `super` keyword
B. It represents an unknown type
C. It allows you to specify that the type must be a superclass of `T`
D. It allows any type to be used as a generic
Answer: Option C
What is the main purpose of generics in Java?
A. To enable type-safe collections and eliminate type casting
B. To increase program execution speed
C. To simplify the syntax of Java code
D. To improve memory management
In a generic class, what does the wildcard `>` represent?
A. A wildcard type
B. A specific class
C. An unknown type
D. An exception type
What is the benefit of using generics with collections in Java?
A. It allows collections to store any type of elements
B. It ensures type safety by allowing only specific types of elements
C. It reduces the size of collections
D. It allows collections to store any type of elements
Join The Discussion