Double Dimensional Arrays Flashcards
A 2D array is an _________________ that stores data in _____ and ___________.
array of arrays, rows, columns
Elements in a 2D array are accessed using two __________: the _____________ and the ______________
indices, row index, column index
When declaring a 2D array, you specify the __________ of the elements it will store and a ____________________ for the array
data type, reference variable
A 2D array where each row can have a different number of columns is called a ______________
jagged array
TRUE or FALSE
In Java, it is possible to initialize a double-dimensional array with only columns initialized; you must define rows first
False, it is not possible
__________________ storage means that elements of a 2D array are stored in memory __________.
This is used in languages like Java, C, and C++
Row-major order, row by row
Which of the following is a common application of 2D arrays mentioned in the source?
a) Representing linked lists
b) Representing matrices
c) Implementing stacks
d) Creating hash tables
b) Representing matrices
How does Java fundamentally treat a 2D array?
a) As a single block of memory with two offsets
b) As an array where each element is another array
c) As a collection of key-value pairs
d) As a tree-like data structure
b) As an array where each element is another array
In which memory storage order are 2D array elements typically accessed more efficiently in Java?
a) Row-Major Order
b) Column-Major Order
c) Diagonal Order
d) Reverse Row-Major Order
a) Row-Major Order
What is the primary purpose of using the Object[][] type for a 2D array in Java?
a) To improve memory efficiency
b) To enable automatic resizing of the array
c) To store elements of different data types
d) To simplify array indexing
c) To store elements of different data types
A 2D array where all rows have the same number of columns.
Rectangular Array
A 2D array where each row can have a different number of columns.
Jaggede Array
The process of going through each element of a 2D array, often using nested loops.
Traversal
The type of error that occurs when you try to access an element in a 2D array using an index that is outside the valid range of rows or columns.
ArrayIndexOutOfBoundsException
The order of storing 2D array elements in memory where all elements of the first column are stored consecutively, followed by the elements of the second column, and so on.
Column-Major Order
The order of storing 2D array elements in memory where all elements of the first row are stored consecutively, followed by the elements of the second row, and so on.
Row-Major Order
The number of horizontal groupings of elements in a 2D array.
Rows
The number of vertical groupings of elements in a 2D array.
Columns
The act of assigning initial values to the elements of a 2D array when it is created.
Initialization
A loop structure in Java that simplifies iterating over the elements of an array without explicitly using indices, but always processes 2D arrays in row-major order.
Enhanced For Loop