a. public class A<E> { … }
b. public class A<E, F> { … }
c. public class A(E) { … }
d. public class A(E, F) { … }
#
9. To declare an interface named A with a generic type, use
a. public interface A<E> { … }
b. public interface A<E, F> { … }
c. public interface A(E) { … }
d. public interface A(E, F) { … }
#
10. To declare an interface named A with two generic types, use
a. public interface A<E> { … }
b. public interface A<E, F> { … }
c. public interface A(E) { … }
d. public interface A(E, F) { … }
#
11. To create a list to store integers, use
a. ArrayList<Object> list = new ArrayList<>();
b. ArrayList<Integer> list = new ArrayList<>();
c. ArrayList<int> list = new ArrayList<int>();
d. ArrayList<Number> list = new ArrayList<>();
#
Section 19.4 Generic Methods
12. The method header is left blank in the following code. Fill in the header.
public class GenericMethodDemo {
public static void main(String[] args ) {
Integer[] integers = {1, 2, 3, 4, 5};
String[] strings = {“London”, “Paris”, “New York“, “Austin”};
print(integers);
print(strings);
}
{
for (int i = 0; i < list.length; i++)
System.out.print(list[i] + ” “);
System.out.println();
}
}
a. public static void print(Integer[] list)
b. public static void print(String[] list)
c. public static void print(int[] list)
d. public static void print(Object[] list)