What is the output of the following code? public class ex { public static void…

PYQ RPSC Programmer 2024

What is the output of the following code? public class ex { public static void main(String[] args) { int[] a = {1, 2, 3, 4, 5}; print(a); } public static void print(int[] a) { for(int n : a) { System.out.print(n + " "); } } }

  1. A.

    Compilation error

  2. B.

    5 4 3 2 1

  3. C.

    Runtime error

  4. D.

    1 2 3 4 5

  5. E.

    Question not attempted

Attempted by 284 students.

Sign up free to check your answer

Sign up free

Explore the full course: Rpsc Programmer

Loading lesson…