public class Demo {
private int x = 10;
public int compute() {
int x = 5;
return this.x + x;
}
}
// ...
Demo d = new Demo();
System.out.println(d.compute());What is printed?
- A
20
- Bcheck_circle
15
- C
10
- D
5
Explanation
this.x refers to the instance variable (10) and x refers to the local (5); the sum is 15.