public class Helper {
public static void inc(int n) { n++; }
}
// ...
int x = 5;
Helper.inc(x);
System.out.println(x);What is printed?
- Acheck_circle
5
- B
6
- C
0
- D
Compile-time error
Explanation
Java passes primitives by value; modifying the parameter n inside inc does not affect x.