Multiple choice general knowledge history

public class Question { public static void main(String args[]) { int x=y=10; y=12; System.out.print(x+"&"+y); } }

  1. 10 & 12

  2. 10 & 10

  3. Compile Time Error

  4. None

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The code int x=y=10; attempts to declare variables x and y and assign them values in a single statement. In Java, this syntax is invalid because y is being used before it has been declared - you cannot chain variable declarations like this when the first variable doesn't exist yet. The correct way would be int y=10, x=y; or declare them separately. Therefore, a compile-time error occurs.