Mauricio Archbold Babroza wrote:
why the answer is true true???
if the code the f1 and z does not have final the answer is the same???
check carefully the FizzSwitch(Fizz x, Fizz y) method.
It assigns the first Fizz argument to a final Fizz z. Then you change the x variable, and return the same Fizz object, except that now Fizz.x = 6
Yes, you can change the object variables even if the object is declared final. Only thing you can't do with a final object is to re-assign it. For example, you cannot write
In effect you are passing f1 and f2 to fizzSwitch() method and getting back f1 (with f1.x = 6). The result is assigned to f3.
f1 and f3 will be the same because both f1 and f3 are references to the same object. Changes in either f1 or f3 will reflect each other because of this.
Eve if you take out 'final', result will be same. I think the final is added to create more confusion!
SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3,OCJP8 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator