Bird
0
0

Which of the following expressions correctly uses the AND (&&) operator in Kotlin?

easy📝 Conceptual Q2 of 15
Kotlin - Operators and Expressions
Which of the following expressions correctly uses the AND (&&) operator in Kotlin?
Aval result = true && false
Bval result = true & false
Cval result = true || false
Dval result = !true | false
Step-by-Step Solution
Solution:
  1. Step 1: Identify the AND operator syntax

    In Kotlin, the logical AND operator is written as &&.
  2. Step 2: Check each option

    val result = true && false uses && correctly. val result = true & false uses a single &, which is a non-short-circuit logical AND operator. val result = true || false uses || which is OR. val result = !true | false uses | which is OR.
  3. Final Answer:

    val result = true && false -> Option A
  4. Quick Check:

    Logical AND syntax = correct [OK]
Quick Trick: Use && for logical AND, not & [OK]
Common Mistakes:
MISTAKES
  • Using & instead of &&
  • Confusing AND with OR
  • Negating incorrectly with !

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes