What is the correct output of this code?
java
List<? extends Number> list = new ArrayList<Integer>();
list.add(5);
Q.42Medium
Which wildcard usage follows the Producer pattern?
Q.43Medium
What does 'covariance' mean in the context of Java Generics?
Q.44Medium
What is the PECS principle in Java Generics?
Q.45Medium
Which of these is a valid generic interface implementation?
Advertisement
Q.46Medium
What is the runtime class object for this generic variable?
java
List<String> list = new ArrayList<String>();
Class<?> c = list.getClass();
Q.47Medium
A developer creates a generic method that accepts a collection of numbers and calculates their sum. Which type parameter declaration would be most appropriate for this scenario?
Q.48Medium
A utility class needs a method that accepts a List containing elements that are instances of a specific class or its subclasses. Which wildcard notation should be used?
Q.49Medium
In a microservices architecture, you're designing a Response wrapper class that should work with any data type, including primitives when boxed. Which implementation is correct?