🎙 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 8 of 10

Which statement about var count = 10; is true?

Which statement about var count = 10; is true?

  1. A.count can later hold a String
  2. B.The compiler infers the type int, and it stays int
  3. C.var makes count a constant
  4. D.var can also be used for class fields
Answer & explanation

Correct answer: The compiler infers the type int, and it stays int

var only saves typing; the variable still has one fixed type, and it works only for local variables with an initial value.

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 →