Where is the reserved type name var not allowed in Java?
Correct answer C. As the declared type of a field
Explanation
Local variable type inference with var applies to local declarations that have an initialiser, including for-loop variables and try-with-resources resources. Fields, method parameters and return types must state their types explicitly, because they form part of a class's visible contract. Writing var count = 0; as a class member is a compile-time error.
Answer checked How we write and check questions
Discussion