Card 25 / 76: Which of the statements are correct? (Choose all that apply.)
A)
3.0 is a valid literal for an int.
B)
3.0 is a valid literal for a float.
C)
3 is a valid literal for an int.
D)
3 is a valid literal for a float.
E)
3f is a valid literal for an int.
Answer:
C) 3 is a valid literal for an int.
D) 3 is a valid literal for a float.
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
C is correct because an int is used to store an integer number.
D is correct because the compiler will automatically convert 3 to a floating-point number.
A, B, and E are incorrect.
A is incorrect because an int cannot store a decimal number.
B is incorrect because 3.0f would be a valid literal for a float, but 3.0 would not (the compiler treats 3.0 as a double).
E is incorrect because an int cannot have f appended to it.
|