will it? Why don't you try the following piece of code? truncated. If you wish to have a good deal of insight into these conversions, then I would suggest you look Language Specifications. So if you look through the language specs, chapter 5 of it will explain stuff in a very clear manner. Hope this helps
Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Thanks for the reply. I obviously need to do a bit more reading on the subject :-) I've got the exam tomorrow so I'm panicing a bit now. I tried the link that you gave me but it took me to the api specs. Was this intentional? I can't find a chapter 5 (I'm not that familiar with the java docs).
Integer division is a strange creature until you get used to it. The way I think about any operation is that the two operands (on the left and right of the operator) MUST be the same type. The result is also the type of the two operands. In many of the choices as answers to this question, the operands aren't the same type. However, Java has several rules that allows it to convert between primitive types automatically. In the case of x / 7, this conversion is not necessary, though, since both x and 7 are ints. This also means the result will be an int (not a double). So how do we get an int value when x does not divide by 7 evenly? The answer is truncation; the remainder is ignored. So in your example, 9 / 7 is 1! You can see this by compiling and running Vijayendra's code example above.