Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago