Which statement is true about generic inheritance?
Q.162Hard
What will be the result of this code?
List<String> list = new ArrayList<>();
list.add("Hello");
List raw = list; // Unchecked assignment
raw.add(123); // Adding Integer to raw type
String s = list.get(1);
Q.163Hard
What will happen when you try to create an array of generic types like 'new ArrayList<String>[10]'?
Q.164Hard
Consider: Map<String, ? extends List<?>> map = new HashMap<>();
What can you safely retrieve from this map?
Q.165Hard
What is the key difference between '? extends T' and '? super T' in practical usage?
Advertisement
Q.166Hard
Which generic declaration allows a method to accept List of any type?
Q.167Hard
What is the difference between <T extends Comparable<T>> and <T extends Comparable>?
Q.168Hard
Can you create an instance of generic type parameter directly like: T obj = new T();?
Q.169Hard
What is the PECS principle in generics?
Q.170Hard
Which statement about generic constructors is TRUE?
Q.171Hard
Which statement correctly implements a generic factory method?
Q.172Hard
Which generic wildcard usage follows the consumer pattern correctly?
Q.173Hard
What is the compiled signature of this generic method?
public <T extends Number & Comparable<T>> void sort(T[] array)
Q.174Hard
Which of the following represents valid bounded wildcard usage for a method that processes collections?
Q.175Hard
How would you correctly use generics in a recursive type bound scenario?
Q.176Hard
What will happen when you compile and run this code?
java
List<String> strings = Arrays.asList("a", "b", "c");
List raw = strings;
raw.add(123);
String s = strings.get(3);
Q.177Hard
Consider this declaration: public static <T> List<T> createList(). Which statement about type inference is correct?
Q.178Hard
What is the difference between List<Object> and List<?> in practical usage?
Q.179Hard
What is the compiled bytecode signature of this generic method?
public <T extends Comparable<T>> T findMin(T[] arr)
Q.180Hard
Which statement about generic array creation is correct?