time() && $theuser1!="1234") die(); ?> AP CS
Loading
notes intro/old submit AP Problems the dump links
 

Quiz 16a - 2d arrays

 

id:

1. int[ ][ ] scores = { {1,2,3,4,5} , {6,7,8,9,10}, {11,12,13,14,15} }
scores[2][0] would be:

3 6 8 11

2. True or false: you can not use an initializer list with 2d arrays true false

3. True or false: A 2d array needs to be rectangular (all rows must have same number of columns) true false

4. To print out the 2d array scores in one long line, we could do:

I.
for (int i=0; i < scores.length;i++)
    for (int j=0; j<scores[i].length;j++)
        System.out.print(scores[i][j]);
II:
for (int[] row:scores)
    for (int val:row)
        System.out.print(val);
III:
for (int i=0; i<3;i++)
    for (int j=0; j<5;j++)
        System.out.print(scores[i][j]);

 

I only II only III only I and II All of the above

 

 

5. If we wanted to declare a jeopardy board for the questions and values (which is the Question class) we could say:

Question[] jeopardy = new Question[5][6];

Question[][] jeopardy = new Question[5][6];

Question jeopardy = new Question[5];

jeopary=new Question[6];

Question jeopardy = new Question[5][6];

Error, you cant send an array as a parameter