Bird
0
0

What will be the output of this Kotlin code?

medium📝 Predict Output Q5 of 15
Kotlin - Operators and Expressions
What will be the output of this Kotlin code?
val x = 5
val y = 5
println(x != y)
Atrue
Bfalse
C5
Dnull
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the expression x != y

    Since both x and y are 5, they are equal, so x != y is false.
  2. Step 2: Print the boolean result

    The println statement will output false.
  3. Final Answer:

    false -> Option B
  4. Quick Check:

    Not equal check = false [OK]
Quick Trick: != returns false if values are equal [OK]
Common Mistakes:
MISTAKES
  • Thinking != returns true when values are equal
  • Confusing output with variable values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes