🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.long n = 10;
  2. B.double d = 5;
  3. C.float f = 2.5;
  4. 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 →