View the step-by-step solution to:

Question

# hi! So

this question appeared on my quiz. Originally I guessed the answer as "3" but as you can see, the answer is "7". Can you please show me or teach me how I'm supposed to get "7" as the answer to this question please? The topic is double dimensional arrays.

24. Consider the following code segment.
int oldArray = {1, 2, 3, 4, 5, 6, 7, 8, 9 );
int newArray = new int [3] [3] ;
int row = 0;
int col = 0;
2
for (int value : oldArray)
newArray [row] [col] = value;
row++;
if ( (row \$ 3) == 0)
2
{
colt+;
odd butdivisible by 3
row = 0;
N
4
System. out . println (newArray [0] [2]) ;
What is printed as a result of executing the code segment?
2
(A) 3
LY
(B) 4
C
5
(D) 7
(E) 8

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents