Bird
0
0

What is the default value of elements in an IntArray created with size 4 in Kotlin?

easy📝 Conceptual Q2 of 15
Kotlin - Collections Fundamentals
What is the default value of elements in an IntArray created with size 4 in Kotlin?
Anull
B0
C-1
Dundefined
Step-by-Step Solution
Solution:
  1. Step 1: Recall default initialization of IntArray

    In Kotlin, IntArray elements are initialized to 0 by default.
  2. Step 2: Match default value with options

    Only 0 correctly states 0 as the default value.
  3. Final Answer:

    0 -> Option B
  4. Quick Check:

    IntArray default value = 0 [OK]
Quick Trick: IntArray elements default to zero [OK]
Common Mistakes:
MISTAKES
  • Assuming null as default
  • Thinking default is -1
  • Believing elements are uninitialized

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes