Computer Applications
How does the amount of storage (in bytes) depend upon type and size of an array? Explain with the help of an example.
Java Arrays
1 Like
Answer
The amount of storage depends upon the type and size of an array as every data type requires different storage space in memory and the number of elements (size) of an array determines how many memory blocks of same size are required.
To calculate the amount of storage required by an array we use the formula:Size = size of data type x number of elements in an array
For example, int arr[] = new int[10]; will require 4 x 10 = 40 bytes space in memory.
Answered By
1 Like
Related Questions
What are different types of arrays? Give examples of each array type.
Write a note on how single-dimension arrays are represented in memory.
What do you understand by two-dimensional arrays ? State some situations that can be easily represented by two-dimensional arrays.
How are two-dimensional arrays represented in memory ?