OCA Java SE 8 Operators/Statements - OCA Mock Question Operator and Statement 20








Question

Which of the following Java operators can be used with boolean variables? (Choose all that apply)

  1. ==
  2. +
  3. --
  4. !
  5. %
  6. <=




Answer



A, D.

Note

A is the equality operator and can be used on numeric primitives, boolean values, and object references.

B and C are both arithmetic operators and cannot be applied to a boolean value.

D is the logical complement operator and is used exclusively with boolean values.

E is the modulus operator, which can only be used with numeric primitives.

F is a relational operator that compares the values of two numbers.