Bird
0
0

What is the default value of elements in a newly created integer array in Java?

easy📝 Conceptual Q2 of 15
Java - Arrays
What is the default value of elements in a newly created integer array in Java?
Aundefined
Bnull
C1
D0
Step-by-Step Solution
Solution:
  1. Step 1: Recall default initialization of arrays in Java

    When an integer array is created, all elements are automatically set to zero by default.
  2. Step 2: Differentiate from other types

    Unlike objects which default to null, primitive int arrays default to 0.
  3. Final Answer:

    0 -> Option D
  4. Quick Check:

    Integer array default = 0 [OK]
Quick Trick: Primitive arrays default to zero values in Java [OK]
Common Mistakes:
  • Thinking default is null
  • Assuming undefined values
  • Assuming default is 1

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes