Bird
0
0

Which of the following is the correct way to declare a mutable integer variable named count with initial value 10 in Kotlin?

easy📝 Syntax Q12 of 15
Kotlin - Variables and Type System
Which of the following is the correct way to declare a mutable integer variable named count with initial value 10 in Kotlin?
Aval count: Int = 10
Bval count = 10
Cvar count: Int
Dvar count = 10
Step-by-Step Solution
Solution:
  1. Step 1: Identify mutable variable declaration

    To declare a mutable variable, use var with an initial value.
  2. Step 2: Check syntax correctness

    var count = 10 correctly declares a mutable integer variable with initial value 10.
  3. Final Answer:

    var count = 10 -> Option D
  4. Quick Check:

    Mutable variable needs var and initial value [OK]
Quick Trick: Use var with initial value for mutable variables [OK]
Common Mistakes:
MISTAKES
  • Using val instead of var for mutable variables
  • Declaring var without initial value or type
  • Confusing val and var syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes