What is a Java 2D array?
A Java 2D array is an array whose elements are themselves arrays. The first index selects the row, and the second selects the column.
Study Java 2D Arrays: Traversal and Grid Algorithms with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a Java 2D array?
A Java 2D array is an array whose elements are themselves arrays. The first index selects the row, and the second selects the column.
How do you find 2D-array dimensions?
For scores, scores.length gives the number of rows, while scores[row].length gives the number of columns in that specific row.
What does new int[3][4] create?
new int[3][4] creates three rows with four integer elements per row. Each element initially contains 0.
What does scores[2][1] identify?
In a rectangular array, scores[2][1] refers to row 2, column 1. With zero-based indexing, this is the third row and second column.
What is row-major traversal?
Row-major traversal processes every element of row 0, then every element of row 1, continuing through the final row.
What order does column-major traversal use?
For grid = {{1, 2, 3}, {4, 5, 6}}, column-major order visits 1, 4, 2, 5, 3, 6.
Which bound should traverse a row safely?
The inner loop should use col < data[row].length. This uses the current row's column count instead of assuming rows and columns are equal.
How does rowSum process one row?
A row sum fixes the row index and varies the column index: for (int col = 0; col < data[row].length; col++) sum += data[row][col].
How does columnSum process one column?
A column sum fixes the column index and varies the row index: for (int row = 0; row < data.length; row++) sum += data[row][col].
Why does a 2D-array average need a double cast?
Cast the sum to double before division, as in (double) sum / count. Otherwise, integer division can discard the fractional part.
How should a maximum search be initialized?
Initialize max with data[0][0], not 0. This works even when every array value is negative.
What is short-circuiting in a 2D-array search?
A search for any matching element can return immediately when the condition is true. For example, containsNegative returns true at the first value below 0, then returns false if none is found.
A progressive guide to how computing reshapes culture, economic life, public institutions, and individual opportunities, with frameworks for evaluating digital equity, bias, cybersecurity, encryption, and collective participation.
A medium-difficulty assessment of programming fundamentals, algorithmic problem solving, control flow, data structures, testing, debugging, complexity, and decidability. Questions progress from foundational understanding to applied reasoning.
A 14-question quiz on the social, economic, privacy, informational, health, and environmental risks of computing innovations, including strategies for responsible design and oversight.
A practical guide to recognizing cybersecurity threats, protecting accounts and devices, and responding safely when information or systems may be compromised.
A guided introduction to how encryption, authentication, hashing, secure protocols, and key management establish confidentiality, integrity, privacy, and trust while creating practical and legal trade-offs.
A focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
A practical guide to evaluating computing innovations by examining their benefits, risks, equity, security, participation, and long-term effects on people and communities.
A medium-difficulty quiz on integrating problem definition, representation, algorithms, complexity analysis, testing, correctness, ethical evaluation, and documentation in a computer science capstone.
A progressive guide to designing, operating, and testing systems that continue useful service despite component faults, overload, data loss, and recovery challenges.
A medium-difficulty quiz on how independently operated networks, protocols, addresses, naming systems, transport services, and routing mechanisms work together to form the Internet.
A progressive guide to how packet-switched networks encapsulate data, move it across links, and manage delay, throughput, queues, and congestion.
A structured guide to designing parallel and distributed systems through decomposition, communication, coordination, state management, scalability, and fault tolerance.