What is the output of running class GenericMethodDemo of the following code? pub
ID: 3927565 • Letter: W
Question
What is the output of running class GenericMethodDemo of the following code?
public class GenericMethodDemo {
public static void main(String[] args ) {
Integer[] integers = {1, 2, 3, 4, 5};
String[] strings = {"London", "Paris", "Dhaka",
"Austin", "Sydney"};
GenericMethodDemo.<Integer>print(integers);
GenericMethodDemo.<String>print(strings);
}
public static <E> void print(E[] list) {
for (int i = 0; i < list.length; i++){
System.out.print(list[i] + " ");
}
System.out.println();
}
}
What is the output of running class GenericMethodDemo of the following code?
public class GenericMethodDemo {
public static void main(String[] args ) {
Integer[] integers = {1, 2, 3, 4, 5};
String[] strings = {"London", "Paris", "Dhaka",
"Austin", "Sydney"};
GenericMethodDemo.<Integer>print(integers);
GenericMethodDemo.<String>print(strings);
}
public static <E> void print(E[] list) {
for (int i = 0; i < list.length; i++){
System.out.print(list[i] + " ");
}
System.out.println();
}
}
Explanation / Answer
output 1 :
London
Paris
Dhaka
Austin
Sydney
The above is the output of hte above program
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.