DEVFYI - Developer Resource - FYI

What is the result in program? <

Java Interview Questions and Answers (part 3)


(Continued from previous question...)

401. What is the result in 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?
A. The output is “Equal”
B. The output in “Not Equal”
C. An error at " if (x = y)" causes compilation to fall.
D. The program executes but no output is show on console.

Answer: C

(Continued on next question...)

Other Interview Questions