Correct Answer:
B. List of Integer and its superclasses
EXPLANATION
'? super Integer' is a lower bounded wildcard that accepts Integer and all its superclasses like Number, Object. This allows write operations with Integer values.
What is the primary purpose of bounded type parameters in generics?
ATo restrict type arguments to specific types or their subtypes
BTo improve code readability only
CTo increase runtime performance
DTo create multiple inheritance in Java
Correct Answer:
A. To restrict type arguments to specific types or their subtypes
EXPLANATION
Bounded type parameters like <T extends Number> restrict the types that can be passed as type arguments, ensuring type safety and enabling access to specific methods.
What is the key difference between '? extends T' and '? super T' in practical usage?
AExtends is for reading data safely, Super is for writing data safely
BExtends is for writing, Super is for reading
CThey have no practical difference
DExtends is for classes, Super is for interfaces
Correct Answer:
A. Extends is for reading data safely, Super is for writing data safely
EXPLANATION
Upper bounds (? extends T) are safe for reading because the compiler knows it's at least T. Lower bounds (? super T) are safe for writing because you can pass T or any superclass.