Consider the following code:
1. for (int i = 0; i < 2; i++) {
2. for (int j = 0; j < 3; j++) {
3. if (i == j) {
4. continue;
5. }
6. System.out.println("i = " + i + " j = " + j);
7. }
8. }
Which lines would be part of the output? (Choose all that apply.)
A. i = 0 j = 0
B. i = 0 j = 1
C. i = 0 j = 2
D. i = 1 j = 0
E. i = 1 j = 1
F. i = 1 j = 2 ** Answ** b,c,d,f
Consider the following code:
1. outer: for (int i = 0; i < 2; i++) {
2. for (int j = 0; j < 3; j++) {
3. if (i == j) {
4. continue outer;
5. }
6. System.out.println("i = " + i + " j = " + j);
7. }
8. }
Which lines would be part of the output? (Choose all that apply.)
A. i = 0 j = 0
B. i = 0 j = 1
C. i = 0 j = 2
D. i = 1 j = 0
E. i = 1 j = 1
F. i = 1 j = 2 ** Answ** d
Which of the following are legal loop constructions? (Choose all that apply.)
A. while (int i<7) {
i++;
System.out.println("i is " + i);
}
B. int i = 3;
while (i) {
System.out.println("i is " + i);
, }
C. int j = 0;
for (int k=0, j+k != 10; j++,k++) {
System.out.println("j=" + j + ", k=" + k);
}
D. int j=0;
do {
System.out.println("j=" + j++);
if (j==3)
continue loop;
} while (j<10); ** Answ** c
What would be the output from this code fragment?
1. int x = 0, y = 4, z = 5;
2. if (x > 2) {
3. if (y < 5) {
4. System.out.println("message one");
5. }
6. else {
7. System.out.println("message two");
8. }
9. }
10. else if (z > 5) {
11. System.out.println("message three");
12. }
13. else {
14. System.out.println("message four");
15. }
A. message one
B. message two
C. message three
D. message four ** Answ** d
Which statement is true about the following code fragment?
1. int j = 2;
2. switch (j) {
3. case 2:
4. System.out.println("value is two");
5. case 2 + 1:
6. System.out.println("value is three");
7. break;
8. default:
9. System.out.println("value is " + j);
10. break;
11. }
A. The code is illegal because of the expression at line 5.