Bird
0
0

What is the default value of elements in a newly declared int array in Java?

easy📝 Conceptual Q2 of 15
Java - Arrays
What is the default value of elements in a newly declared int array in Java?
Anull
B1
Cundefined
D0
Step-by-Step Solution
Solution:
  1. Step 1: Recall default initialization of primitive arrays

    In Java, when an int array is created, all elements are automatically set to 0.
  2. Step 2: Verify options

    Only 0 matches the default value 0. null is for object references, undefined is not a Java concept, and 1 is incorrect.
  3. Final Answer:

    0 -> Option D
  4. Quick Check:

    Default int array value = 0 [OK]
Quick Trick: Primitive arrays default to zero values in Java [OK]
Common Mistakes:
  • Assuming arrays have undefined or garbage values
  • Confusing default values for objects and primitives

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes