Which of the following is the correct way to declare a variable in Java?
Show answerHide answer
Correct answer: (D) int x = 10;
Explanation
Java is statically typed, so a variable is declared with its type: int x = 10;. let is JavaScript, and var x = 10 works only as local type inference from Java 10, so the standard answer is int.