logo Practice-It logo

ReferenceMystery2

Language/Type: Java
Author: Marty Stepp (on 2020/04/16)

The following program produces 3 lines of output. Write each line of output below as it would appear on the console.

    public class ReferenceMystery2 {
       public static void main(String[] args) {
          int x = 2;
          int y = 5;
          int[] data = {10, 20, 30};
          mystery1(x, data);
          System.out.println(x + " " + Arrays.toString(data));
          x = mystery2(x, y);
          System.out.println(x + " " + y);
       }

       public static void mystery1(int x, int[] data) {
          x = x * 2;
          data[2] = x - 1;
          System.out.println(x + " " + Arrays.toString(data));
       }

       public static int mystery2(int y, int x) {
          y++;
          x--;
          return x + y;
       }
    }
line 1
line 2
line 3

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.