Kotlin Conditional Statements
Kotlin Conditional Statements - Important Points
11. | Which of the following is an example of a when statement? |
---|
A. if (condition) { } else { }
B. when (expression) { case value -> statements }
C. switch (expression) { case value: statements; default: statements; }
D. None of the above.
View Answer Discuss Work SpaceAnswer: option b
Explanation:
12. | Which of the following is true about the "if-else if" statement in Kotlin? |
---|
A. It is used to check multiple conditions.
B. It can be used as a replacement for the switch statement.
C. It can be nested within other conditional statements.
D. All of the above.
View Answer Discuss Work SpaceAnswer: option d
Explanation:
13. | What is the syntax for the if-else if statement? |
---|
A. if (condition) { } else if (condition) { } else { }
B. if (condition) { } else { } if (condition) { }
C. if (condition) { } if (condition) { } else { }
D. if { } else if { } else { }
View Answer Discuss Work SpaceAnswer: option a
Explanation:
14. | Which of the following is an example of an if-else if statement? |
---|
A. if (condition) { } else { }
B. if (condition) { } else if (condition) { } else { }
C. switch (expression) { case value: statements; default: statements; }
D. None of the above.
View Answer Discuss Work SpaceAnswer: option b
Explanation:
15. | What is the purpose of the "when" expression in Kotlin? |
---|
A. To check multiple conditions.
B. To return a value based on a condition.
C. To execute a block of code if a condition is true.
D. None of the above.
View Answer Discuss Work SpaceAnswer: option b
Explanation: