← 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?
- A.count can later hold a String
- B.The compiler infers the type int, and it stays int
- C.var makes count a constant
- 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 →