hi guys,
juz going thro self-test q's in kathy sierra, in chapter 3 therez this question :
class PassA {
public static void main(
String [] args) {
Pass p = new PassA();
p.start();
}
void start() {
long [] a1 = {3,4,5};
long [] a2 = fix(a1);
System.out.print(a1[0] + a1[1] + a1[2] + " ");
System.out.println(a2[0] + a2[1] + a2[2]);
}
long [] fix(long [a3] ) {
a3[1]=7;
return a3;
}
}
what is the result?
A. 12 15
B. 15 15
C. 3 4 5 3 7 5
D. 3 7 5 3 7 5
E. Compilation fails
F. An exception is thrown at runtime
Kathy says its B, since a1 and a3 refer to the same long array object.
I had this slight doubt that this answer would be right if the first print statement does not contain an " ".
Since it contains " ", shouldnt't the String Concatenation rule be applied, and it should simply print 375 15 ?
am i missing somethin in here?