What is delay() in Kotlin Coroutines?
Suspends the coroutine without blocking the thread
A loop control
Constructs methods dynamically
References constructors
43 practice sets · Page 2 of 3
What is delay() in Kotlin Coroutines?
Suspends the coroutine without blocking the thread
A loop control
Constructs methods dynamically
References constructors
What are Coroutines in Kotlin?
Constructor references
Lightweight threads for asynchronous programming
A loop control mechanism
Placeholders for arrays
What is the purpose of the by keyword in Kotlin?
Type casting
Inheritance
Delegation
Annotation processing
What is the difference between == and === in Kotlin?
Both check for equality
== checks reference equality, and === checks structural equality
== checks structural equality, and === checks reference equality
Both check structural equality
What does the Elvis operator (?:) do in Kotlin?
Performs null checks
Throws exceptions
Converts types
Provides a default value if the left-hand expression is null
Kotlin uses 1 and 0 to represent Boolean values.
True
False
Which of the following is a correct way to create a list in Kotlin?
val myList = listOf("A", "B", "C")
val myList = mutableList("A", "B", "C")
val myList = ListOf("A", "B", "C")
val myList = createList("A", "B", "C")
Which function is used to iterate over a collection in Kotlin?
iterate()
forEach()
loop()
foreach()
Which of the following is a correct example of a lambda expression in Kotlin?
fun (x, y) = x + y
(x: Int, y: Int) => x + y
lambda(x, y -> x + y)
{ x, y -> x + y }
What is the purpose of the sealed class in Kotlin?
To prevent nullability issues
To define a class with only static members
To create a hierarchy of related classes with restricted inheritance
To create a mutable class
Which operator is used in Kotlin for string interpolation?
$
@
%
What is a data class in Kotlin used for?
To manage multithreading
To define abstract methods
To hold data without boilerplate code
To store immutable objects only
What is the purpose of the fun keyword in Kotlin?
To declare a class
To define a constant
To create a loop
To declare a function
Which keyword is used in Kotlin to declare a mutable variable?
let
mutable
var
val
How do you define a single-line function in Kotlin?
Use the inline keyword
Use an equals sign = followed by the expression
Use curly braces {}
Use the return keyword
Which of the following is used to declare an immutable variable in Kotlin?
const
let
var
val
What does the lateinit keyword in Kotlin indicate?
A variable that is initialized in the constructor
A variable that can never be null
A variable that is private
A variable that is declared but not immediately initialized
What is a primary constructor in Kotlin?
A special member function
A function that initializes variables
A concise way to initialize a class
A type of class
Which of the following are primitive data types in Kotlin?
String, Array, Stack, Queue
Boolean, Byte, Short, Int, Float, Long, Double, Char
There are no Primitive data types in Kotlin only Non-Primitive data types
boolean, byte, short, int, float, long, double, char
Which of the following is a primary feature of Kotlin?
Null safety
No semicolons
Lambda expressions
All of the mentioned