Multiple choice technology programming languages

Read the following program: public class test { public static void main(String [] args) { int x = 3; int y = 1; if (x = y) System.out.println("Not equal"); else System.out.println("Equal"); } } What is the result?

  1. The output is “Equal”

  2. The output in “Not Equal”

  3. An error at " if (x = y)" causes compilation to fall.

  4. The program executes but no output is show on console.

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

The code uses assignment (=) instead of comparison (==) inside the if statement: if (x = y). In Java, this is a compilation error because the if condition requires a boolean expression, but assignment returns an int value. Java does not allow numeric types in conditional contexts.