Computer Applications

Write a note on how single-dimension arrays are represented in memory.

Java Arrays

3 Likes

Answer

Single-dimensional arrays are lists of information of the same type and their elements are stored in contiguous memory locations in their index order.

Internally, arrays are stored as a special object containing :

  1. A group of contiguous memory locations that all have the same name and same datatype.
  2. A reference that stores the beginning address of the array elements.
  3. A separate instance variable containing the number of elements in the array.

For example, an array grade of type char with 8 elements declared as

char grade[ ] = new char[8];

will have the element grade[0] at the first allocated memory location, grade[1] at the next contiguous memory location, grade[2] at the next, and so forth. Since grade is a char type array, each element size is 2 bytes and it will be represented in memory as shown in the figure given below:

Write a note on how single-dimension arrays are represented in memory. Arrays, Sumita Arora Computer Applications Solutions ICSE Class 10

Answered By

2 Likes


Related Questions