Android

Kotlin Language Essentials for Android

var vs val, null safety, data classes, when expressions, extension functions, scope functions and fundamental Kotlin concepts

24 mülakat soruları·
Junior
1

What is the difference between 'var' and 'val' in Kotlin?

Cevap

'var' declares a mutable (modifiable) variable, while 'val' declares an immutable (read-only) variable. It's recommended to use 'val' by default to promote immutability and avoid bugs.

2

What does the '?' operator after a type mean in Kotlin?

Cevap

The '?' operator indicates that the variable can contain null. For example, 'String?' means the variable can be a String or null. This is the basis of Kotlin's null safety system.

3

What does the '!!' operator do in Kotlin?

Cevap

The '!!' operator (not-null assertion) forces the compiler to treat a nullable value as non-null. If the value is null, a NullPointerException is thrown. Only use when you're certain the value is not null.

4

What is the Elvis operator '?:' used for in Kotlin?

5

What is a data class in Kotlin?

+21 mülakat soruları

Bir sonraki mülakatın için Android'de uzmanlaş

Tüm sorulara, flashcards'a, teknik testlere, code review alıştırmalarına ve mülakat simülatörlerine eriş.

Ücretsiz başla