Bird
0
0

Which of the following is the correct syntax to declare a mutable integer variable score initialized to 0 in Kotlin?

easy📝 Syntax Q3 of 15
Kotlin - Variables and Type System
Which of the following is the correct syntax to declare a mutable integer variable score initialized to 0 in Kotlin?
Aval score = 0
Bvar score = Int 0
Cvar score: Int = 0
Dmutable score = 0
Step-by-Step Solution
Solution:
  1. Step 1: Review Kotlin variable declaration syntax

    To declare a mutable variable with explicit type, use var variableName: Type = value. var score: Int = 0 matches this.
  2. Step 2: Identify incorrect options

    val score = 0 uses val (immutable), var score = Int 0 has invalid syntax, mutable score = 0 uses a non-existent keyword.
  3. Final Answer:

    var score: Int = 0 -> Option C
  4. Quick Check:

    Correct syntax = B [OK]
Quick Trick: Use var name: Type = value for explicit mutable vars [OK]
Common Mistakes:
MISTAKES
  • Using val instead of var for mutable variables
  • Incorrect type declaration syntax
  • Using invalid keywords like mutable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes