ans c is correct because the value of Byte & Double is not final it may be changed so it is not definat that multiplication of them will be in the range of byte(-128 to 127).so it give compile time error if we made both of them final then it will run properly. Amit Madan
Amit, I think the correct answer is that the all math operands are promoted to at least an int before being used in an operation. The operands are both promoted to ints causing the result to be an int which clearly will not fit in a byte. casting it should work. I don't see what final has to do with it.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR> fantastic, a towel? <HR></BLOCKQUOTE>
Amit is very much right, if the variable(of integral data type) are declared as final and their operartion(i.e /, * , +, - etc) remain within their limits, casting is not required.
Muhammad Farooq<br />Sun Certified Programmer for Java 2 Platform<br />Oracle8i Certified Professional Database Administrator
Joined: Dec 20, 2000
Hi binary numeric promotion implicitly appropriate widening primitive conversion so that a pair of operands have the broadest numeric type of two,but which is always at least int. byte,short,char always converted to at least int. here both of them are variable so they can be changed.so multiplication of them can be an integer which may be not in rang of byte so compiler give error with msg ossible loss of precision.so explisit casting requird where definatly loss of precision. if you make them final then value of them are constant so it can't be changed and here multiplication is within the range of byte so then it work properly because no precision loss. Amit Madan