What is type erasure in Java Generics?
Which statement about wildcard generics (?) is correct?
What will happen when you try to create an array of generics?
List<String>[] array = new List<String>[10];
Consider the code:
List<? extends Number> list = new ArrayList<>();
list.add(5); // Will this compile?
Which of the following represents a bounded type parameter?
Advertisement
What is the difference between List<?> and List<Object>?
Consider this generic interface:
interface Comparable<T> { int compareTo(T o); }
Which class definition correctly implements this?
What will be the output?
List<Integer> list = new ArrayList<>();
list.add(10);
Object obj = list.get(0);
System.out.println(obj instanceof Integer);
Which of these declarations would NOT cause a compilation warning or error?
In the declaration 'List<? extends Number> list', what types can be added to this list at runtime?
Which statement correctly uses the lower-bounded wildcard in generics?
Which generic declaration would allow storing both String and Integer in the same collection?
What does the PECS principle stand for in generics context?
In a generic class 'class Box<T extends Comparable<T>>', what constraint is placed on T?
Which generic wildcard usage is INCORRECT?
What is the relationship between raw types and generics in Java?
Consider the method: public static <T> T getFirst(List<T> list) { return list.get(0); }
How would you call this method for a List<String>?
What is the significance of the '&' operator in generic bounds like '<T extends A & B>'?
Which statement about generic type parameters is TRUE?
Consider the declaration: List<? super Integer> list. What does this wildcard represent?