MM

Quiz 2D Array

T

When using a doubly-nested loop to process all of the elements of a two-dimensional array in row-major order, the outer loop will iterate over the rows.

T

When using a doubly-nested loop to process all of the elements of a two-dimensional array in column-major order, the outer loop will iterate over the columns.

F

When using a doubly-nested loop to process all of the elements of a two-dimensional array in column-major order, the outer loop will iterate over the rows.

T

The number of rows and columns in a two-dimensional array need not be the same.

F

The number of rows and columns in a two-dimensional array must be the same.

T

If a two-dimensional array has more rows than columns, then the array can still be processed in both row-major order and column-major order.

T

The declaration and allocation of a two-dimensional array need not be done in the same statement.

F

The declaration and allocation of a two-dimensional array must be done in the same statement.

T

In a two-dimensional array A, the number of columns is given by A\[i\].length, where i is an integer variable containing a valid row number.

T

In a two-dimensional array A, the number of rows is given by A.length.

T

The maximum number of dimensions that a Java array can have is theoretically unlimited, but implementations limit it to 255.

T

The row i of a 2D array of integers can be deleted with row\[i\] = new int\[0\]

F

The row i of a 2D array of integers cannot be deleted with row\[i\] = new int\[0\]

F

The row i of a 2D array of integers can be deleted with row\[i\].length = 0;

T

The row i of a 2D array of integers cannot be deleted with row\[i\].length = 0;

T

The updating section of a for loop may contain multiple statements separated by comma

T

An inner loop initialization and termination conditions may use the control variable of the outer loop

T

An outer loop can have any number of nested inner loop

F

Assuming 0<=pos1<=pos2<=A.length-1, the length of the array with elements pos1 to pos2 is pos2-pos1.

T

Assuming 0<=pos1<=pos2<=A.length-1, the length of the array with elements pos1 to pos2 is pos2-pos1+1.

T

The individual elements of an array A are indexed from 0 to A.length-1.

T

An array need not be always declared and allocated in the same Java statement

T

The number of elements in an array A can be accessed as A.length

F

The number of elements in an array A can be accessed as A\[0\].length

T

The base type of an array include int, double, boolean, char, and String.

F

The base type of an array can be int, double, boolean, char, but not String.

T

int\[\] a = {32, 16, 4, 91, 12}; // This both allocates the space for the array and initializes it T int\[\] A=new int\[10\]; A\[A.length-1\] = 100; would not cause an error (either compiler or run-time)

F

A\[-1\] accesses the last element of the array A T A\[-1\] cannot access the last element of the array A

F

A\[A.length-1\] cannot access the last element of the array A T One cannot enlarge the array A by 1 using A.length++;

F

One can enlarge the array A by 1 using A.length++; T One cannot free a array A from memory by setting its length to zero with A.length=0;

T

The following code would generate an error attempting to set the length of array A to 10: int\[\] A; A\[9\]=0;

T

The following code sets the length of array A to 10: int\[\] A; A=new int\[10\]; A\[9\]=0;

F

The following code would generate an error attempting to set the length of array A to 10: int\[\] A; A=new int\[10\]; A\[9\]=0;

T

int\[\] A; A\[0\]=0; would generate an error attempting to create an array with the first element set to 0;

T

int\[\] A does not create an array with space already allocated, like int A\[\].

F

int\[\] A create an array with space already allocated, unlike int A\[\].

T

int a\[\],b,c; creates an array a and two integer variables b and c.

F

int\[\] a,b\[\],c\[\]; is equivalent with: int a\[\], b\[\],c\[\];

T

int\[\] a,b\[\],c\[\]; is equivalent with: int a\[\], b\[\]\[\],c\[\]\[\];