subject

In this program why can arrays values stored in index be changed in both main method and mystery method, when the array is declared in main as a local variable? when the array is printed in the main method, the chnage took in the mystery method is present, why is this? is it a property of arrays?
public class referencemystery {
public static void main(string[] args) {
int x = 0;
int[] a = new int[4];
x = x + 1;
mystery(x, a);
system. out. println(x + " " + arrays. tostring(a));
x = x + 1;
mystery(x, a);
system. out. println(x + " " + arrays. tostring(a));
}
public static void mystery(int x, int[] a) {
x = x + 1;
a[x] = a[x] + 1;
system. out. println(x + " " + arrays. tostring(a));
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
What type of computer network ensures high security ?
Answers: 1
question
Computers and Technology, 22.06.2019 16:10
Drag each label to the correct location on the imagelist the do’s and don’ts of safeguarding your password.keep yourself loggedin when you leave your computer.don’t write your password down and leave it whereothers can find it.share your password with your friends.each time you visit a website,retain the cookies on your computer.use a long password with mixed characters.
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
Which of the following statements best describes it careers?
Answers: 2
question
Computers and Technology, 23.06.2019 06:40
What are the three uses of a screw?
Answers: 2
You know the right answer?
In this program why can arrays values stored in index be changed in both main method and mystery met...
Questions
question
Mathematics, 05.02.2021 18:20
question
Mathematics, 05.02.2021 18:20
Questions on the website: 13722360