In: Computer Science
Question 1:
What does the following code print to the console when the main method is run?
public static void referenceMystery(int x, int[] a) {
  x = 3;
  a[0] = 4;
  System.out.println(x+" "+a[0]);
}
 
public static void main(String[] args) {
 int x = 1, y = 2;
 int[] a = new int[1];
 int[] b = new int[1];
 referenceMystery(y, b);
}
1. x a[0]
2. 1
3. 2 0
4. 3 4
Question 2:
What does the following code print out when the main method is run?
public static void referenceMystery(int x, int[] a) {
  x = 3;
  a[0] = 4;
}
 
public static void main(String[] args) {
 int x = 1, y = 2;
 int[] a = new int[1];
 int[] b = new int[1];
 referenceMystery(y, b);
 System.out.println(x+" "+a[0]);
}
1. x a[0]
2. 1 0
3. 2 1
4. 3 4