MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The ____ of an Array are indicated by the number of square brackets beside it.
A
Index
B
Elements
C
Array
D
Dimension
Explanation: 

Detailed explanation-1: -: The elements field within square brackets [], representing the number of elementsin the array, must be a constant expression, since arrays are blocks of static memory whose size must be known at compile time.

Detailed explanation-2: -Square brackets are used to index (access) elements in arrays and also Strings. Specifically lost[i] will evaluate to the ith item in the array named lost.

Detailed explanation-3: -The first set of square brackets represents the length of the one-dimensional array (i.e. the number of rows) and the second set of square brackets represents the length of each of the rows (i.e. the number of columns). So the 2D array grades has 3 rows and 4 columns.

Detailed explanation-4: -A 2D array has a type such as int[][] or String[][], with two pairs of square brackets. The elements of a 2D array are arranged in rows and columns, and the new operator for 2D arrays specifies both the number of rows and the number of columns.

There is 1 question to complete.