Use the following code for the matching questions double[] ary1 = { 1.1, -2.2, -
ID: 3917410 • Letter: U
Question
Use the following code for the matching questions
double[] ary1 = { 1.1, -2.2, -3.3, 4.4 };
double[] ary2 = new double[8];
double[] ary3 = ary2;
int numValues = 4;
//-----------------------------------------------------------------
System.out.println("1a: ary1 size=" + ary1.length);
System.out.println("1b: ary2 size=" + ary2.length);
System.out.println("1c: ary3 size=" + ary3.length);
//-----------------------------------------------------------------
for (int ndx = 0; ndx < ary1.length - 1; ndx += 2){
ary2[ndx] = ary1[ndx];
}
System.out.println("2a: ");
for (int ndx = 0; ndx < numValues; ndx++){
System.out.print(ary3[ndx] + ", ");
}
System.out.println();
//-----------------------------------------------------------------
ary3 = new double[5];
int ndx2 = 0;
for (int ndx = 0; ndx < ary1.length - 1; ndx++){
if (ary1[ndx] < 0.0){
ary3[ndx2] = ary1[ndx];
ndx2++;
}
}
System.out.print("2b: ");
for (int ndx = 0; ndx < ndx2; ndx++){
System.out.print(ary3[ndx] + ", ");
}
System.out.println();
//-----------------------------------------------------------------
Indicate the output produced
1a: ary1 size = ______
?
1b: ary2 size = ____
?
1c: ary3 size = ____
?
2a: ____________________________
?
2b: ____________________
A. 2
B. 1.1, 2.2, -3.3, 4.4,
C. -2.2, -3.3,
D. 4
E. 8
F. 1.1, 0.0, -3.3, 0.0,
G. 0.0, -3.3,
Explanation / Answer
here is the output of the given code..
1a: ary1 size=4
1b: ary2 size=8
1c: ary3 size=8
2a:
1.1, 0.0, -3.3, 0.0,
2b: -2.2, -3.3,
hence option which are Bold below are correct.
A. 2
B. 1.1, 2.2, -3.3, 4.4,
C. -2.2, -3.3,
D. 4
E. 8
F. 1.1, 0.0, -3.3, 0.0,
G. 0.0, -3.3,
========================================================
Kindly Check and Verify Thanks..!!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.