Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. The following program produces 4 lines of output. Write the output below, as it would appear on the console. import java.util.*; public class ReferenceMystery{
1. The following program produces 4 lines of output. Write the output below, as it would appear on the console.
import java.util.*;
public class ReferenceMystery{
public static void main(String [] args){
int y=1;
int x=3;
int [] a = new int[4];
mystery(a,y,x);
System.out.println(x+" "+y+" "+Arrays.toString(a));
x=y-1;
mystery(a,y,x);
System.out.println(x+" "+y+" "+Arrays.toString(a));
}
public static void mystery(int[] a, int x, int y){
if (x x++ a[x] = 17; } else{ a[y} = 17; } System.out.println(x+" "+y+" "+Arrays.toString(a)); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started