Kotlin Conditional Statements
Kotlin Conditional Statements - Important Points
16. | Which of the following is true about the "if-let" statement in Kotlin? |
---|
A. It is used to check if a variable is null.
B. It can be used as a replacement for the if-else statement.
C. It can be nested within other conditional statements.
D. All of the above.
View Answer Discuss Work SpaceAnswer: option d
Explanation:
17. | What is the syntax for the if-let statement? |
---|
A. if (variable != null) { } else { }
B. if (variable) { } else { }
C. if (variable == null) { } else { }
D. if (variable?.let { } ) { } else { }
View Answer Discuss Work SpaceAnswer: option d
Explanation:
18. | Which of the following is an example of an if-let statement? |
---|
A. if (variable != null) { } else { }
B. if (variable) { } else { }
C. if (variable == null) { } else { }
D. if (variable?.let { } ) { } else { }
View Answer Discuss Work SpaceAnswer: option d
Explanation:
19. | What is the purpose of the "unless" expression in Kotlin? |
---|
A. To check multiple conditions.
B. To execute a block of code if a condition is true.
C. To execute a block of code if a condition is false.
D. None of the above.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
20. | What is the syntax for the unless expression? |
---|
A. unless (condition) { }
B. if (condition) { } else { }
C. unless { } else { }
D. unless (condition) { } else { }
View Answer Discuss Work SpaceAnswer: option a
Explanation: