← Quiz: Java Data Types: all 10 questions
Quiz: Java Data Types · Question 3 of 10
Which line does NOT compile?
Which line does NOT compile?
- A.long n = 10;
- B.double d = 5;
- C.float f = 2.5;
- D.int i = 'A';
Answer & explanation
Correct answer: float f = 2.5;
2.5 is a double literal; assigning it to float needs 2.5f or a cast.
Can you get the rest right without peeking?
Take the timed Quiz: Java Data Types quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →