Quiz 2D Array

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/42

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

43 Terms

1
New cards

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.

True

2
New cards

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.

True

3
New cards

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.

False

4
New cards

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

True

5
New cards

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

False

6
New cards

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.

True

7
New cards

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

True

8
New cards

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

False

9
New cards

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.

True

10
New cards

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

True

11
New cards

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

True

12
New cards

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

True

13
New cards

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

False

14
New cards

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

False

15
New cards

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

True

16
New cards

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

True

17
New cards

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

True

18
New cards

An outer loop can have any number of nested inner loop

True

19
New cards

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

False

20
New cards

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

True

21
New cards

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

True

22
New cards

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

True

23
New cards

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

True

24
New cards

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

False

25
New cards

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

True

26
New cards

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

False

27
New cards

int\[\] a = {32, 16, 4, 91, 12}; // This both allocates the space for the array and initializes it

True

28
New cards

int\[\] A=new int\[10\]; A\[A.length-1\] = 100; would not cause an error (either compiler or run-time)

True

29
New cards

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

False

30
New cards

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

True

31
New cards

A\[A.length-1\] cannot access the last element of the array A

False

32
New cards

One cannot enlarge the array A by 1 using A.length++;

True

33
New cards

One can enlarge the array A by 1 using A.length++;

False

34
New cards

One cannot free a array A from memory by setting its length to zero with A.length=0;

True

35
New cards

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

True

36
New cards

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

True

37
New cards

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;

False

38
New cards

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

True

39
New cards

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

True

40
New cards

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

False

41
New cards

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

True

42
New cards

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

False

43
New cards

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

True