Ask Question

What is output by the following code?

public static void stuff (int w) {

w - = 2;

}

public static void main (String a[]) {

int n = 2;

stuff (n);

System. out. print (n);

}

1. 0

2. 4

3. 1

4. 3

5. 2

+2
Answers (1)
  1. 13 October, 19:45
    0
    The output is 2. The stuff () function receives a copy of n, changes it but the result is never used.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What is output by the following code? public static void stuff (int w) { w - = 2; } public static void main (String a[]) { int n = 2; stuff ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers