What will be written to the standard output when the following
program is executed?
A.000 B.001 C.010 D.100 E.101
The answer is E.101
I was quite sure the answer was 001 as the copy of the variable are passed. So the value 111 would be true with in g() . And f() would have the original value of a and b as 0. Only the value of array would change after returning from g().
Can some one explain this. [ September 08, 2008: Message edited by: Nabila Mohammad ]
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Here is the previous code, with "this" added to where the instance variables are used. Note that g, since a is not a parameter to the method, actually alters the instance variable a, resulting in "1" "0" (b is unchanged, g uses its own copy) and 1 (c is passed as the reference to the array, and the actual int stored at 0 is set to 1 in g()).