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 equality operator ‘==’ is used to check if a and b have the same value.
B
Since a and b both equal 3, the condition evaluates to true and prints ‘Equal’.
C
The comparison a == b properly compares the two integer values for equality.
D
The if statement uses the assignment operator ‘=’ to mistakenly compare a and b.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE