Given:
public class Main { final static int mine = 7; final static Integer i = 57; public static void main(String[] args) { int x = go(mine); System.out.print(mine + " " + x + " "); x += mine;/*w w w . j a va 2 s .co m*/ Integer i2 = i; i2 = go(i); System.out.println(x + " " + i2); i2 = new Integer(60); } static int go(int x) { return ++x; } }
What is the result?
D is correct.
None of the final variables are modified.
The "i2" variable initially refers to the same object as the final "i" variable, but that object can be modified, and "i2" can be referred to a different object.
Autoboxing allows an Integer to work with go()
's int argument.