Java Programming - Language Fundamentals - Discussion
Discussion Forum : Language Fundamentals - General Questions (Q.No. 12)
12.
Which three are valid declarations of a float?
- float f1 = -343;
- float f2 = 3.14;
- float f3 = 0x12345;
- float f4 = 42e7;
- float f5 = 2001.0D;
- float f6 = 2.81F;
Answer: Option
Explanation:
(1) and (3) are integer literals (32 bits), and integers can be legally assigned to floats (also 32 bits). (6) is correct because (F) is appended to the literal, declaring it as a float rather than a double (the default for floating point literals).
(2), (4),and (5) are all doubles.
Discussion:
36 comments Page 4 of 4.
Yaz said:
1 decade ago
thnks sundar
SALISU said:
1 decade ago
Why 3 is declared as a float.
Vaibhavi said:
1 decade ago
oh.. thanks for explanation sundar..
i have read it somewhere...
i have read it somewhere...
Himanshu said:
1 decade ago
Why float 3.14 is not valid?
Disha said:
1 decade ago
I also did not understand the same concept.
How do we find the range and find whether its double or float?.
How do we find the range and find whether its double or float?.
Bhanu Prasad said:
1 decade ago
float f2 = 3.14;
This is not float why ?
This is not float why ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers