Programming practice

Java 2D arrays practice

Each question shows a Java snippet that creates a matrix and performs operations on it, then asks what the code prints to the console. Choose "No loops" for direct cell access and dimension questions, or "With loops" for nested loop problems including row sums, column traversal, diagonal access, and full matrix iteration.

Advertisement

Interactive question set

Read each snippet carefully. Identify the matrix contents, then trace the access or loop. For multi-line output, enter each printed value on its own line in the text area. Remember that matrix.length is the number of rows and matrix[0].length is the number of columns.

Advertisement