Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(LO4_LO6) What output is produced by the following code fragment? int num = 87,

ID: 657940 • Letter: #

Question

(LO4_LO6) What output is produced by the following code fragment?

int num = 87, max = 25;
if (num <= max * 2)
        System.out.println ("Apple");
System.out.println ("Orange");

(LO4_LO6) What output is produced by the following code fragment?

int num = 0, max = 13;
while (num < max){
        if ( num %5 == 0)
                        System.out.print (num + " " );
        num++;
}

(LO4_LO6) What output is produced by the following code fragment?

for (int i = 0; i < 7; i += 2)
        System.out.print (i + " ");

(LO4_LO6) What output is produced by the following code fragment?

int total = 10;
int max = 30;

total = (total > max) ? total + 1: total * 2;
System.out.println (total);

(LO4_LO6) What output is produced by the following code fragment?

int num = 10;
int max = 30;
while (num < max) {
        if (num == max/2){
                        num += 5;
        continue;
}
System.out.print(num + " ");
num += 5;
}

(LO4_LO6) What output is produced by the following code fragment?
ArrayList <String> names = new ArrayList <String>();
names.add ("Andy");
names.add ("Betty");
names.add (1, "Chet");
names.add (1, "Don");
names.remove(2);
System.out.println(names);

(LO4_LO6) What output is produced by the following code fragment?

int number = 10;
while (number > 0) {
        number = number - 2;
        if (number == 4)
                        break;
        System.out.print (number+" ");
}

(LO6) Trace the code below and write its output in the box.

public class FigureOut {

public static void main (String [] args) {
                int [] numbers = {10, 5, 100, 25, 50, 12};
                mystery1(numbers);
                mystery2(numbers);
}

public static void mystery1(int [] numbers) {
                int temp;
                for (int i = numbers.length -2; i >= 0; i--) {
                                for (int j= 0; j <= i; j++)
                                                if (numbers [j] < numbers [j+1]) {
                                                                temp = numbers [j];
                                                                numbers [j] = numbers [j+1];
                                                                numbers [j+1] = temp;
                                                }
                }
                numbers [0] = -9;
                numbers [numbers.length-1] = 99;
} // method mystery1

public static void mystery2 (int[] list) {
                for (int i = 0; i < list.length; i++)
                                System.out.print (list[i] + " ");
}

       } // class FigureOut

(LO6) Given the code below. What is the output?
        int n = 0;
        for (int i = 0; i < 10; i++)
                        for (int j = 15; j > 5; j--)
                                        for (int k = 0; k <= 5; k++)
                                                        for (int l =0; l < 5; l++)
                                                        n++;
        System.out.println (

Explanation / Answer

1. orange

2. 0 5 10

3. 0 2 4 6

4. 20

5. 10 20 25

7. 8 6

8. -9 50 25 12 10 99

9. N= 3000

10. Line and laugh!!!

MeMe

youVSU

FallHer2012