Reference Mutation Check
A method accepts an object reference and performs a modification to the underlying object instance fields.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
static class Container {
int data = 0;
}
public static void main(String[] args) {
Container c = new Container();
modify(c);
System.out.print(c.data);
}
static void modify(Container obj) {
obj.data = 20;
}
}
A
0
B
10
C
20
D
null
Question Leaderboard
Not enough data yet to show leaderboard.
