Which of the following is NOT a characteristic of an abstract class in Kotlin?
It cannot have properties.
It cannot be instantiated.
It can have non-abstract methods with implementation.
It can have abstract methods without implementation.
When is it appropriate to use the lateinit keyword in Kotlin?
lateinit
When you want to define a constant value.
When you want to create a custom exception class.
When you want to initialize a non-nullable property later in the code, typically when you are certain it will be assigned a non-null value before its first use.
When you want to make a property nullable.
How can you find the first element in a list that satisfies a given condition?
first()
filter().first()
find()
search()
Which of the following is a valid way to define an extension function for the String class in Kotlin?
String.fun newMethod() {}
extension fun String.newMethod() {}
fun String.newMethod() {}
fun newMethod(str: String) {}
What is the purpose of the StringBuilder class in Kotlin?
StringBuilder
To create immutable strings.
To efficiently build mutable strings.
To perform regular expression matching.
To convert between different string encodings.
Which of these is NOT a common use case for sealed classes in Kotlin?
Defining an extensive inheritance hierarchy.
Creating algebraic data types.
Representing a finite set of possible states.
Modeling a closed type system.
What keyword is used to call the superclass implementation of an overridden method from within the subclass?
parent
base
this
super
How can you safely access a property of a nullable object in Kotlin?
By directly accessing the property using the dot (.) operator.
.
By using the safe call operator ?..
?.
Nullable objects cannot have their properties accessed in Kotlin.
By using the non-null assertion operator !!.
!!
How does a suspending function differ from a regular function in Kotlin?
Suspending functions cannot return values, while regular functions can.
Suspending functions are deprecated and should be replaced with regular functions.
Suspending functions are executed on separate threads, while regular functions run on the main thread.
Suspending functions can be paused and resumed, allowing for non-blocking asynchronous operations.
Which function type represents a function that takes an Int and returns a String?
String(Int)
(Int) -> String
Int.() -> String
(Int) -> Unit