Answer:
? super T method is used to replace YYYYYYYY in the following code, such that the call to add(stack1, stack2)
public class WildCardDemo3 {
public static void main(String[] args) {
GenericStack<String> stack1 = new GenericStack<>();
GenericStack<Object> stack2 = new GenericStack<>();
stack2.push("Java");
stack2.push(2);
stack1.push("Sun");
add(stack1, stack2);
WildCardDemo2.print(stack2);
}
public static <T> void add(GenericStack<T> stack1,
GenericStack<YYYYYYYY> stack2) {
while (!stack1.isEmpty())
stack2.push(stack1.pop());
}
}
Explanation:
super can be used to refer immediate parent class instance variable. super can be used to invoke immediate parent class method. super() can be used to invoke immediate parent class constructor.