Kotlin Conditional Statements
Kotlin Conditional Statements - Important Points
6. | Which of the following is an example of an if-else statement? |
---|
A. if (condition) { } else { }
B. if (condition) { }
C. switch (expression) { case value: statements; default: statements; }
D. None of the above.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
7. | Which of the following is an example of a switch statement? |
---|
A. if (condition) { } else { }
B. if (condition) { }
C. switch (expression) { case value: statements; default: statements; }
D. None of the above.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
8. | What is the purpose of the "default" case in a switch statement? |
---|
A. To check for a specific condition.
B. To execute a block of code if none of the cases match.
C. To execute a block of code if the switch expression is null.
D. None of the above.
View Answer Discuss Work SpaceAnswer: option b
Explanation:
9. | Which of the following is true about the "when" statement in Kotlin? |
---|
A. It is used to check multiple conditions.
B. It is similar to the switch statement in Java.
C. It can be used as a replacement for if-else and switch statements.
D. All of the above.
View Answer Discuss Work SpaceAnswer: option d
Explanation:
10. | What is the syntax for the when statement? |
---|
A. when (expression) { case value -> statements }
B. when (expression) { case value -> statements; default -> statements }
C. when (expression) { value -> statements }
D. when (expression) { value -> statements; default -> statements }
View Answer Discuss Work SpaceAnswer: option a
Explanation: