Android

Kotlin Collections and Operators

Kotlin Collections, functional operators (map, filter, reduce), Sequences, higher-order functions, operator overloading

20 питань зі співбесід·
Mid-Level
1

What is the difference between List and MutableList in Kotlin?

Відповідь

List is a read-only interface that doesn't allow modifying the collection after creation. MutableList extends List and adds modification methods like add(), remove(), clear(). List guarantees structural immutability.

2

How do you create an immutable list in Kotlin?

Відповідь

Use listOf() to create an immutable list. This function returns a read-only List<T>. For a mutable list, use mutableListOf() or arrayListOf().

3

What is the map() operator used for on a collection?

Відповідь

map() transforms each element of the collection by applying a function, and returns a new list with the transformed elements. For example: listOf(1,2,3).map { it * 2 } returns [2,4,6].

4

What is the filter() operator used for?

5

What is the difference between map() and flatMap()?

+17 питань зі співбесід

Опануй Android для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно