Java Equality Operator for Integers
All of the following statements about the if statement in the provided code segment are true EXCEPT:
public class Main {
public static void main(String[] args) {
int a = 3, b = 3;
if (a == b) {
System.out.println("Equal");
}
}
}
A
The if statement uses the assignment operator ‘=’ to mistakenly compare a and b.
B
The comparison a == b properly compares the two integer values for equality.
C
Since a and b both equal 3, the condition evaluates to true and prints ‘Equal’.
D
The equality operator ‘==’ is used to check if a and b have the same value.
Question Leaderboard
Not enough data yet to show leaderboard.
