MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What does the 2pair of square brackets mean in two dimensional arrays?
A
Width and Height
B
Column and Row
C
X and Y
D
None of the above
Explanation: 

Detailed explanation-1: -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-2: -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.

Detailed explanation-3: -Accessing Values The data elements in two dimesnional arrays can be accessed using two indices. One index referring to the main or parent array and another index referring to the position of the data element in the inner array.If we mention only one index then the entire inner array is printed for that index position.

Detailed explanation-4: -Arrays in Java can store many items of the same type. You can even store items in two-dimensional (2D) arrays which are arrays that have both rows and columns. A row has horizontal elements. A column has vertical elements.

There is 1 question to complete.