COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What are the advantages of arrays?
A
Objects of mixed data types can be stored
B
Elements in an array cannot be sorted
C
Index of first element of an array is 1
D
Easier to store elements of same data type
Explanation: 

Detailed explanation-1: -In arrays, the elements can be accessed randomly by using the index number. Arrays allocate memory in contiguous memory locations for all its elements. Hence there is no chance of extra memory being allocated in the case of arrays. This avoids memory overflow or shortage of memory in arrays.

Detailed explanation-2: -An array stores a collection of items at adjoining memory locations. Items that are the same type are stored together so the position of each element can be calculated or retrieved easily by an index. Arrays can be fixed or flexible in length.

Detailed explanation-3: -A. Easier to store elements of same data type. B. Used to implement other data structures like stack and queue. C. Convenient way to represent matrices as a 2D array. D. All of the mentioned.

There is 1 question to complete.