| 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 1 students
Absolute Value of 2D Array Elements
< Prev
Next >

Consider the following code segment.

int m = // some positive integer
int n = // some positive integer
int[][] table = new int[m][n];
// input values into table

for (int row = 0; row < table.length; row++)
    for (int col = 0; col ‹ table[0].length; col++)
        if (table[row][col] < 0)
            table[row][col] = - table[row][col];

Which of the following best describes the result of executing the code segment?

A

Each element in the two-dimensional array table contains the value row - col.

B

Each element in the two-dimensional array table contains a nonnegative value.

C

Each element in the two-dimensional array table contains the opposite value from when it was initialized.

D

Each element in the two-dimensional array table contains the value 0.

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy