Java : ​What is the output of the following program?

Programming
Tutor: None Selected Time limit: 1 Day

What is the output of the following program?

 

public class ReferenceMystery1 {

     public static void main(String[] args) {

          int x = 0;

          int[] a = {0, 0, 0, 0};

          x++;

          mystery(x, a);

          System.out.println(x + " " + Arrays.toString(a));

     }

 

     public static void mystery(int x, int[] a) {

          x++;

          a[x] += 1;

          System.out.println(x + " " + Arrays.toString(a));

     }

}

Oct 15th, 2015

Thank you for the opportunity to help you with your question!

The answer : 

 the output.JPG 


Please if you don't understand something just ask i will answer you

I am glad to work with you just invite me each time you have any others question i will give you the best answers

GOod Luck



Please let me know if you need any clarification. I'm always happy to answer your questions.
Oct 15th, 2015

that's it, what about if you do line 3 and 4. that will be the same result

Oct 15th, 2015

what ?? i don't understand your question 

Oct 15th, 2015

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Oct 15th, 2015
...
Oct 15th, 2015
Dec 9th, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer