Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote