Given the following code:
What is the output?
Java passes the int argument by value, so incrementing the method parameter changes it from 1000 to 1001 only within myMethod. The expression this.x refers to the instance field, which remains 100. The local variable in main also remains 1000, producing 10011001000.
int
1000
1001
myMethod
this.x
100
main
10011001000
Community Discussion