Q. What is the correct definition of an array?

  • (A) An array is a set of elements of the same type stored in non-contiguous memory locations
  • (B) An array is a set of elements of the same type stored in contiguous memory locations
  • (C) An array is a set of elements
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) An array is a set of elements of the same type stored in contiguous memory locations
Explanation:

An array in programming (especially in C/C++, Java, etc.) is defined as:

A collection of elements of the same data type, stored in contiguous memory locations, and accessed using an index.

Example in C:

int arr[3] = {10, 20, 30};
  • All elements are of type int
  • They are stored in memory one after another (contiguous)
  • Can be accessed using index: arr[0], arr[1], arr[2]

❌ Option A is incorrect:

Non-contiguous memory would imply a linked list, not an array.

βœ… Correct Answer: (B)

Explanation by: Mr. Dubey

An array in programming (especially in C/C++, Java, etc.) is defined as:

A collection of elements of the same data type, stored in contiguous memory locations, and accessed using an index.

Example in C:

int arr[3] = {10, 20, 30};
  • All elements are of type int
  • They are stored in memory one after another (contiguous)
  • Can be accessed using index: arr[0], arr[1], arr[2]

❌ Option A is incorrect:

Non-contiguous memory would imply a linked list, not an array.

βœ… Correct Answer: (B)

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
188
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
84%
Success Rate