Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
About Exam
easy Solved by 4 students

2D Array Traversal With Step

< Prev
Next >

Consider the following method:

public void editArray(int[][] data) {
    for (int row = 0; row < data.length; row += 2) {
        for (int col = 0; col < data[row].length; col++) {
            data[row][col] = -data[row][col];
        }
    }
}

Given an array data initialized as follows:

{
  {-1, -2, -3}, 
  {4, 5, 6}, 
  {7, 8, 9}, 
  {10, 11, 12}
}

What will the array look like after the method execution?

A

1, 2, 3
4, 5, 6
-7, -8, -9
-10, -11, -12

B

1, 2, 3
4, 5, 6
7, 8, 9
10, 11, 12

C

-1, -2, -3
4, 5, 6
7, 8, 9
10, 11, 12

D

1, 2, 3
4, 5, 6
-7, -8, -9
10, 11, 12

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki11 0m 00s 100
#2winstonhou110701 0m 00s -10
#3y.seong202712 1m 40s -10
#4bommasam00013 11m 52s -632
Items per page:
10
1 – 4 of 4

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|