Bird
0
0

Which of the following is the correct Kotlin syntax to check if variable a is not equal to variable b?

easy📝 Syntax Q12 of 15
Kotlin - Operators and Expressions
Which of the following is the correct Kotlin syntax to check if variable a is not equal to variable b?
Aa != b
Ba <> b
Ca =! b
Da !== b
Step-by-Step Solution
Solution:
  1. Step 1: Recall Kotlin syntax for inequality

    Kotlin uses != to check if two values are not equal.
  2. Step 2: Verify each option

    a != b is correct; a <> b is invalid in Kotlin; a =! b is incorrect syntax; a !== b checks referential inequality, not value inequality.
  3. Final Answer:

    a != b -> Option A
  4. Quick Check:

    Not equal operator = != [OK]
Quick Trick: Use '!=' for not equal, never '<>' in Kotlin [OK]
Common Mistakes:
MISTAKES
  • Using '<>' which is not valid in Kotlin
  • Swapping '=' and '!' in 'a =! b'
  • Confusing '!=' with '!==', which checks references

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes