posted 22 years ago
This is from Marcus Green's Mock Exam.
Which of the following are legal statements?
1) float f=1/3;
2) int i=1/3;
3) float f=1.01;
4) double d=999d;
Answers: 1,2,4
How are 1 and 2 legal? I thought a numerical literal containing a decimal component was interpreted as a double. Going by that logic, 1 and 2 should be double values which should be illegal statements.
Can someone clarify?
Thanks
Sharda