214k views
0 votes
AP CSA Question:

I'm reviewing a test and can't get past this problem:

What is the difference between printing (n) and printing row[n]?

AP CSA Question: I'm reviewing a test and can't get past this problem: What is the-example-1
User Xandross
by
6.3k points

1 Answer

2 votes

Answer:

The answer is "Option A"

Explanation:

Complete Code:

public class Arr//defining a class-Arr

{

public static void main(String[] args)//main method

{

int [][] numbers={{1, 2, 3},{4,5,6}}; //defining 2D array numbers

for(int[] row : numbers) //use for loop that holds all array value into 1D array

{

for (int n: row)//defining n variable that holds row array values

{

System.out.print (n); //print n variable value

}

}

}

}

The code comment explains its functioning.

User Ram Vennam
by
6.0k points