# Need programming help with a java question (((Output of arrays)))

Anonymous
timer Asked: Nov 15th, 2015
account_balance_wallet \$5

### Question Description

1) List all values that the array ia will contain after the following code is executed:

int[] ia = new int[10];

ia[8] = 6;

ia[4] = ia[8];

ia[7] = 8;

ia[3] = -30;

ia[6] = 3;

ia[2] = 6;

ia[3] = 7;

ia[5] = 2 * ia[4];

ia[0] = 1;

ia[1] = ia[0];

int i = ia[6];

ia[6] = 9;

ia[i] = ia[4] * ia[8];

ia[9] = 31;

shyamnair3
School: Duke University

Thank you for the opportunity to help you with your question!

-----------------------------------------------------------------------------

int[] ia = new int[10];

So the array ia can store 10 integer values in ia[0] to ia[9].

Lets start with ia[0] and move forward.

ia[0] = 1;

ia[1] = ia[0];

which means ia[1] = 1

ia[2] = 6;

ia[3] = -30;

But then it is changed to

ia[3] = 7;

Again it is changed

ia[6] = 3;

int i = ia[6]; // i = 3

ia[i] = ia[4] * ia[8]; //ia[3] = ia[4] * ia[8] = 6 * 6 = 36

which means ia[3] in the end will contain 36.

ia[8] = 6;

ia[4] = ia[8];

which means ia[4] = 6

ia[5] = 2 * ia[4];

which means ia[5] = 2 * 6 = 12

ia[6] = 3;

But then it is changed to

ia[6] = 9;

ia[7] = 8;

ia[8] = 6;

ia[9] = 31;

So the values that the array ia will contain after the following code is executed is

ia[0] = 1;

ia[1] = 1

ia[2] = 6;

ia[3] = 36

ia[4] = 6

ia[5] = 12

ia[6] = 9;

ia[7] = 8;

ia[8] = 6;

ia[9] = 31;

-----------------------------------------------------------------------------

Please let me know if you need any clarification. I'm always happy to answer your questions.

flag Report DMCA
Review

Anonymous
Tutor went the extra mile to help me with this essay. Citations were a bit shaky but I appreciated how well he handled APA styles and how ok he was to change them even though I didnt specify. Got a B+ which is believable and acceptable.

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors