Java OCA OCP Practice Question 493

Question

What statement about the ^ operator is correct?

  • A. If one of the operands of ^ is true, then the result is always true.
  • B. There is a conditional form of the operator, denoted as ^^.
  • C. If both operands of ^ are true, the result is true.
  • D. The ^ operator can only be applied to boolean values.


D.

Note

The exclusive or (XOR) ^ operator requires evaluating both operands to determine the result.

Options A and B are incorrect.

For Option B, you can't have a short-circuit operation if both operands are always read, therefore ^^ does not exist.

Option C is an incorrect statement as the ^ operator only returns true if exactly one operand is true.

Option D is correct as the ^ is only applied to boolean values in Java.




PreviousNext

Related