This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
A. float f1 = -343; B. float f2 = 3.14; C. float f3 = 0x12345; D. float f4 = 42e7; E. float f5 = 2001.0D; F. float f6 = 2.81F;
The answer is A,D,F .
B is not correct because floating-point numbers are considered doubles. If you want a float you must mark it as such. 3.14F C is not correct because you can only have ints in hex or octal format. A is correct because an int fits into a float. (it's not a floating point number so you don't need the F is this case) D.....erm - you can just represent floats with the e scientific notation. again you dont need the f because its not a floating point number.