Kotlin Basics
Kotlin Basics - Important Points
16. | What is a coroutine in Kotlin? |
---|
A. A type of function that can be suspended and resumed later.
B. A type of loop that runs in the background.
C. A type of class that is used for creating objects.
D. A type of variable that can be shared between threads.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
17. | Which of the following is true about extension functions in Kotlin? |
---|
A. Extension functions are a way to add new functionality to existing classes without having to modify their source code.
B. Extension functions can only be defined for classes that are part of the Kotlin standard library.
C. Extension functions are not supported in Kotlin.
D. Extension functions can only be defined for classes that are marked as "open".
View Answer Discuss Work SpaceAnswer: option a
Explanation:
18. | What is the Elvis operator in Kotlin? |
---|
A. A type of operator used for bitwise operations.
B. A type of operator used for arithmetic operations.
C. A type of operator used for null safety.
D. A type of operator used for logical operations.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
19. | What is the difference between "val" and "var" in Kotlin? |
---|
A. val is used for variables that can be changed, while "var" is used for variables that are constant.
B. val is used for variables that are constant, while "var" is used for variables that can be changed.
C. val and "var" are interchangeable and can be used interchangeably.
D. val and "var" are not supported in Kotlin.
View Answer Discuss Work SpaceAnswer: option b
Explanation:
20. | What is the difference between "is" and "as" in Kotlin? |
---|
A. is is used for type checking, while "as" is used for casting between types.
B. is is used for casting between types, while "as" is used for type checking.
C. is and "as" are interchangeable and can be used interchangeably.
D. is and "as" are not supported in Kotlin.
View Answer Discuss Work SpaceAnswer: option a
Explanation: