Kotlin Basics
Kotlin Basics - Important Points
| 6. | Which of the following is an example of a string interpolation in Kotlin? |
|---|
A. The answer is + answer
B. The answer is $answer
C. The answer is {answer}
D. The answer is [answer]
View Answer Discuss Work SpaceAnswer: option b
Explanation:
| 7. | Which of the following is a valid function declaration in Kotlin? |
|---|
A. fun myFunction()
B. fun myFunction(): String
C. fun myFunction(): Int = 42
D. All of the above
View Answer Discuss Work SpaceAnswer: option d
Explanation:
| 8. | What is the syntax for a lambda expression in Kotlin? |
|---|
A. {x, y -> x + y}
B. (x, y) => x + y
C. [x, y] -> x + y
D. (x, y) -> {x + y}
View Answer Discuss Work SpaceAnswer: option d
Explanation:
| 9. | What is the Elvis operator in Kotlin? |
|---|
A. ??
B. ::
C. !!
D. //
View Answer Discuss Work SpaceAnswer: option a
Explanation:
| 10. | Which of the following is true about nullable types in Kotlin? |
|---|
A. All types in Kotlin are nullable by default.
B. Only reference types in Kotlin can be nullable.
C. All types in Kotlin are non-nullable by default.
D. Nullable types cannot be used in Kotlin.
View Answer Discuss Work SpaceAnswer: option c
Explanation: