Which of the following is the correct way to declare a variable in Java?
- Alet x = 10;
- Bx = 10;
- Cvar x = 10;
- Dint x = 10;
Correct answer: D
Explanation
In Java, a variable is declared with its data type, as in int x = 10;. 'let' is JavaScript and 'var' (type inference) works only in newer versions inside methods. Discussion 0
Nobody has replied yet. Start the discussion!