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:
Step 1: Identify the AND operator syntax
In Kotlin, the logical AND operator is written as &&.
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.
Final Answer:
val result = true && false -> Option A
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 !
Master "Operators and Expressions" in Kotlin
9 interactive learning modes - each teaches the same concept differently