0
0
Android Kotlinmobile~5 mins

Collections (List, Map, Set) in Android Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a List in Kotlin collections?
A List is an ordered collection of elements that can contain duplicates. You can access elements by their index.
Click to reveal answer
beginner
How does a Set differ from a List in Kotlin?
A Set is a collection that holds unique elements only. It does not maintain insertion order and does not allow duplicates.
Click to reveal answer
beginner
What is a Map in Kotlin collections?
A Map stores key-value pairs. Each key is unique and maps to exactly one value.
Click to reveal answer
beginner
How do you create an immutable List in Kotlin?
Use listOf() function. For example: val myList = listOf("apple", "banana") creates a read-only list.
Click to reveal answer
intermediate
What function creates a mutable Map in Kotlin?
Use mutableMapOf(). For example: val myMap = mutableMapOf("key1" to 1, "key2" to 2) creates a map you can change.
Click to reveal answer
Which Kotlin collection type allows duplicate elements and maintains order?
AList
BSet
CMap
DNone of the above
What happens if you add a duplicate element to a Kotlin Set?
AIt adds the duplicate
BIt ignores the duplicate
CIt throws an error
DIt replaces the existing element
How do you access a value in a Kotlin Map?
ABy index
BBy value
CBy key
DBy position
Which function creates a mutable List in Kotlin?
AlistOf()
BmapOf()
CsetOf()
DmutableListOf()
What is the key characteristic of a Kotlin Map?
AIt stores key-value pairs with unique keys
BIt stores only unique values
CIt stores ordered elements
DIt stores only numbers
Explain the differences between List, Set, and Map in Kotlin collections.
Think about how each collection stores and accesses data.
You got /3 concepts.
    Describe how to create and use a mutable List and a mutable Map in Kotlin.
    Focus on the functions and what mutability means.
    You got /3 concepts.