Bird
0
0

Which Kotlin feature is enabled by using expressions instead of statements?

easy📝 Conceptual Q2 of 15
Kotlin - Control Flow as Expressions
Which Kotlin feature is enabled by using expressions instead of statements?
AAutomatic memory management
BFaster compilation time
CAbility to assign the result of control flow directly to variables
DDisabling null safety
Step-by-Step Solution
Solution:
  1. Step 1: Identify control flow as expressions

    In Kotlin, control flow like if-else can be used as expressions that return values.
  2. Step 2: Assigning results directly

    This allows assigning the result of an if-else expression directly to a variable, improving code clarity.
  3. Final Answer:

    Ability to assign the result of control flow directly to variables -> Option C
  4. Quick Check:

    Control flow as expressions = C [OK]
Quick Trick: Control flow expressions can be assigned directly [OK]
Common Mistakes:
MISTAKES
  • Confusing expression benefits with compilation speed
  • Mixing memory management with expressions
  • Thinking expressions disable null safety

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes