Hi All,
I am having this code from
SCJP book of Kathy Sierra/Bert Bates, Chapter 4 exercise question no. 2
We need to insert the below fragments in code at line no. 7 :
And the following five code fragments:
F1. if(f1 == f2)
F2. if(f1 == f2[2][1])
F3. if(x == f2[0][0])
F4. if(f1 == f2[1,1])
F5. if(f3 == f2[2])
What is true?
A. One of them will compile, only one will be true
B. Two of them will compile, only one will be true
C. Two of them will compile, two will be true
D. Three of them will compile, only one will be true
E. Three of them will compile, exactly two will be true
F. Three of them will compile, exactly three will be true
Answer is D, that F2, F3, and F5 will compile, and only F3 is true.
I can understand for F2 and F5, but little bit confused why the F3 get compiled.
I read somewhere that first boxing takes place and then widening, so if we box the float f2[0][0] to Float we can't wide it to Long. Because there is no hierarchy relation in Long and Float.
are we unBoxing the Long x to long and then comparing it with float? but why ?
Please Help