Kotlin Program - Study Mode

[#221] Which line of code shows how to display a nullable string's length and shows 0 instead of null?
Correct Answer

(B) println(b?.length ?: 0)

[#222] Kotlin interfaces and abstract classes are very similar. What is one thing abstract class can do that interfaces cannot?
Correct Answer

(D) Only abstract classes can store state

[#223] Inside an extension function, what is the name of the variable that corresponds to the receiver object
Correct Answer

(B) The variable is named this

[#224] Which is the proper way to declare a singleton named DatabaseManager?
Correct Answer

(A) Object DatabaseManager {}

[#225] What is the keyword used to define an interface in Kotlin?
Correct Answer

(D) interface