Kotlin (Coding) Quiz
Kotlin language fundamentals: null safety, coroutines, and the modern JVM/Android development idioms.
This category currently has 60 questions in the SERVBG quiz bank. Below are a few sample questions: the full interactive quiz shuffles through the whole set with instant scoring.
Sample questions
In Kotlin, what is the difference between val and var?
- val declares a read-only reference; var declares a mutable reference
- val is local; var is global
- val is for primitives only; var is for objects only
- val is a compile-time constant; var is a runtime variable
- val is nullable; var is non-nullable
How do you declare a nullable String in Kotlin?
- val name?: String = null
- val name: String = null
- val name: String! = null
- val name: String? = null
- nullable String name = null
What does the Elvis operator ?: do?
- Concatenates two strings ignoring nulls
- Forces a non-null assertion at runtime
- Performs safe call and returns Unit
- Returns the left expression if non-null, otherwise the right one
- Compares two objects for structural equality
What does the safe-call operator ?. do on a nullable receiver?
- Calls the member and ignores the return value
- Always returns a default value of zero
- Forces the compiler to treat the receiver as non-null
- Throws NullPointerException when the receiver is null
- Calls the member only if the receiver is non-null, else returns null
What does the !! operator do?
- Negates a Boolean twice
- Performs a bitwise NOT
- Asserts the value is non-null or throws NullPointerException
- Forces the value to become null
- Marks a property as lateinit
Related categories
Python (Coding)
Python syntax and standard-library usage, from quick scripts to full applications.
JavaScript (Coding)
Core JavaScript behavior and async patterns, including the quirks that trip up beginners and veterans alike.
Linux
Linux command-line usage, file permissions, process management. The daily admin tasks.
Security
General information security concepts: common threats and standard defenses.
Hardware
Hardware components, how they interact, and basic troubleshooting to keep systems running.