during the arithematic when the operands are of different types the resulting type is always the widest of the 2 types for which the answer was given as false but i feel the answer is true cause if u add an int + float the result is always float. the answer given was also not clear, but why was it given as false i feel the answer is true can anybody pls explain
posted 16 years ago
What about short i = 3; byte j = 4; What's the result of k = i+j or k = i*j k can't be a short because i and j are automatically promoted to ints during the arithmatic operation - but an int is wider than the widest type of either variable (short). So sometimes when the operands are of different types, they're automatically promoted to something other than the widest type. That's why it's false. Hope this helps, Kathy
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads