Java SE 11 Developer (1Z0-819) — Question 92
Which two var declarations are correct? (Choose two.)
Answer options
- A. var names = new ArrayList<>();
- B. var _ = 100;
- C. var var = “hello”;
- D. var y = null;
- E. var a;
Correct answer: A, C
Explanation
The correct answers are A and C. Option A is valid because it initializes a var with a new ArrayList instance. Option C is incorrect due to using 'var' as a variable name, which is a reserved keyword, making it an invalid declaration. Options B, D, and E are valid but do not meet the criteria for the correct answers.