Bird
0
0

Which of the following is the correct syntax to declare an immutable integer variable named count with value 10 in Kotlin?

easy📝 Syntax Q12 of 15
Kotlin - Variables and Type System
Which of the following is the correct syntax to declare an immutable integer variable named count with value 10 in Kotlin?
Aval count = 10
Bvar count = 10
Cint val count = 10
Dval count : Int =
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct keyword and syntax

    val is used for immutable variables, and Kotlin infers type if not specified.
  2. Step 2: Check each option

    var count = 10 uses var (mutable), C has invalid syntax, D is incomplete.
  3. Final Answer:

    val count = 10 -> Option A
  4. Quick Check:

    Immutable variable syntax = val count = 10 [OK]
Quick Trick: Use val for fixed values, var for changeable ones [OK]
Common Mistakes:
MISTAKES
  • Using var instead of val for immutable variables
  • Incorrect Kotlin type declarations
  • Leaving declarations incomplete

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes