Which statement is true about the following code?
public class Main { static void print1(List<String> lst) { // (1) for(String element : lst) { System.out.print(element + " "); }// w ww. j a v a 2s.c o m } static void print2(List<String> lst) { // (2) for(Object element : lst) { System.out.print(element + " "); } } static void print3(List<?> lst) { // (3) for(Object element : lst) { System.out.print(element + " "); } } static <T> void print4(List<T> lst) { // (4) for(Object element : lst) { System.out.print(element + " "); } } static <T> void print5(List<T> lst) { // (5) for(T element : lst) { System.out.print(element + " "); } } }
Select the one correct answer.
(e)
The methods in (1), (2), and (3) are not generic, but the methods in (4) and (5) are.
A generic method need not be declared in a generic class.
Regardless of what type an object has, it is still an Object.