Which of the following expressions evaluates to true?

  1. (false | true)

  2. (null != null)

  3. (4 <= 4)

  4. (true & false)


Correct Option: A,C

AI Explanation

To answer this question, we need to evaluate each expression and determine which ones evaluate to true.

Option A) (false | true) - This expression uses the bitwise OR operator (|) to combine the values false and true. The result of the bitwise OR operator is true if at least one of the operands is true. In this case, since the second operand is true, the expression evaluates to true.

Option B) (null != null) - This expression checks for inequality between two null values. In Java, null represents the absence of a value. When comparing null values, they are considered equal, so the expression evaluates to false.

Option C) (4 <= 4) - This expression uses the less than or equal to operator (<=) to compare the values 4 and 4. Since 4 is equal to 4, the expression evaluates to true.

Option D) (true & false) - This expression uses the bitwise AND operator (&) to combine the values true and false. The result of the bitwise AND operator is true only if both operands are true. In this case, since one of the operands (false) is false, the expression evaluates to false.

Therefore, the expressions that evaluate to true are A) (false | true) and C) (4 <= 4).

Find more quizzes: