What will be the default values of all the elements of an array defined as an instance variable? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What will be the default values of all the elements of an array defined as an instance variable?

In java

20th Mar 2020, 6:10 AM
Ali Murtuza Khan
Ali Murtuza Khan - avatar
2 Answers
+ 2
Depends on the type of the array you want to create. It will have the default values respective to the data type declared.
20th Mar 2020, 6:22 AM
Avinesh
Avinesh - avatar
0
And If the array is an array of primitive types, then all the elements of the array will be initialized to the default value corresponding to that primitive type
20th Mar 2020, 6:23 AM
Ali Murtuza Khan
Ali Murtuza Khan - avatar