logo Practice-It logo

ReferenceMystery1

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 ReferenceMystery1 {
       public static void main(String[] args) {
          int x = 1;
          int y = 7;
          int[] data = {2, 4, 6};
          mystery1(data[x], data);
          System.out.println(x + " " + Arrays.toString(data));
          x = mystery2(x, y);
          System.out.println(x + " " + y);
       }
       
       public static void mystery1(int z, int[] numbers) {
          z = z + 3;
          numbers[z / 3]++;
          z = 3;
          numbers[z - 2]--;
          System.out.println(z + " " + Arrays.toString(numbers));
       }

       public static int mystery2(int x, int y) {
          y++;
          x = x + y;
          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.