Bird
0
0

Given the Kotlin code:

hard📝 Application Q9 of 15
Kotlin - Operators and Expressions
Given the Kotlin code:
val a = 5
val b = 10
val c = 5
println(a == c && b > a)

What is the output?
A5
Bfalse
CCompilation error
Dtrue
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the first condition a == c

    Since both a and c are 5, a == c is true.
  2. Step 2: Evaluate the second condition b > a

    Since 10 is greater than 5, b > a is true.
  3. Step 3: Combine both conditions with &&

    Both are true, so true && true is true.
  4. Final Answer:

    true -> Option D
  5. Quick Check:

    Logical AND of true and true = true [OK]
Quick Trick: && returns true only if both sides are true [OK]
Common Mistakes:
MISTAKES
  • Assuming && returns false if one side is true
  • Confusing == with =

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes