 # 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;

ia = 6;

ia = ia;

ia = 8;

ia = -30;

ia = 3;

ia = 6;

ia = 7;

ia = 2 * ia;

ia = 1;

ia = ia;

int i = ia;

ia = 9;

ia[i] = ia * ia;

ia = 31;

shyamnair3
School: Duke University   Thank you for the opportunity to help you with your question!

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

int[] ia = new int;

So the array ia can store 10 integer values in ia to ia.

Lets start with ia and move forward.

ia = 1;

ia = ia;

which means ia = 1

ia = 6;

ia = -30;

But then it is changed to

ia = 7;

Again it is changed

ia = 3;

int i = ia; // i = 3

ia[i] = ia * ia; //ia = ia * ia = 6 * 6 = 36

which means ia in the end will contain 36.

ia = 6;

ia = ia;

which means ia = 6

ia = 2 * ia;

which means ia = 2 * 6 = 12

ia = 3;

But then it is changed to

ia = 9;

ia = 8;

ia = 6;

ia = 31;

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

ia = 1;

ia = 1

ia = 6;

ia = 36

ia = 6

ia = 12

ia = 9;

ia = 8;

ia = 6;

ia = 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