Skip to content
CodeKruPro

What is true about var?

QuizEasy-MediumJava only

Which statements about var in Java 21 are true? Pick all that apply.

  • var name = "admin"; gives name the type String at compile time
  • var can be used for fields of a class
  • var x; with no initial value does not compile
  • After var n = 5; you can write n = "five";

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in