Computer Science, asked by rewaasrour2000, 4 months ago

1)can we store objects in an array?
2)what can a standard array hold?

Answers

Answered by yokeshps2005
1

Answer:

1.Yes, since objects are also considered as datatypes (reference) in Java, you can create an array of the type of a particular class and, populate it with instances of that class

2.

Yes, an Object[] can hold any type of Object (you may have to cast it as such when you add one to the array) - a Number[], however, can only hold Number objects (not native ints or Integer object (however if you cast them into Number objects, they will fit nicely)

Answered by Harshabadboy
0

Answer:

1.Yes, since objects are also considered as datatypes (reference) in Java, you can create an array of the type of a particular class and, populate it with instances of that class.

2.Arrays are classified as Homogeneous Data Structures because they store elements of the same type. They can store numbers, strings, boolean values (true and false), characters, objects, and so on. But once you define the type of values that your array will store, all its elements must be of that same type.

Hope it helps ❤❤

Similar questions