Bird
0
0

Which Kotlin function creates an immutable set?

easy📝 Conceptual Q1 of 15
Kotlin - Collections Fundamentals
Which Kotlin function creates an immutable set?
AarrayOf()
BmutableSetOf()
ClistOf()
DsetOf()
Step-by-Step Solution
Solution:
  1. Step 1: Understand set creation functions

    In Kotlin, setOf() creates an immutable set, while mutableSetOf() creates a mutable set.
  2. Step 2: Identify immutable set function

    The function setOf() returns a read-only set that cannot be changed after creation.
  3. Final Answer:

    setOf() -> Option D
  4. Quick Check:

    Immutable set creation = setOf() [OK]
Quick Trick: Use setOf() for fixed sets, mutableSetOf() to change later [OK]
Common Mistakes:
MISTAKES
  • Confusing mutableSetOf() with setOf()
  • Using listOf() instead of setOf()
  • Thinking arrayOf() creates a set

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes