NEW
Font size
WorksheetsLoops - I
Total questions: 10
Worksheet time: 3mins
int i = 5;
while (i > 5) {
System.out.print(i);
i--;
}
What is the output?
5
Infinite loop
No output
Compilation error
int i = 5;
do {
System.out.print(i);
i--;
} while (i > 5);
What is the output?
No Output
5
54
Infinite loop
int i = 1;
while (true) {
if (i == 3)
break;
System.out.print(i);
i++;
}
123
12
1
Infinite loop
int i = 1;
while (i <= 5) {
if (i == 4)
break;
System.out.print(i);
i++;
}
123
1234
12345
124
int i = 10;
do {
System.out.print(i + " ");
i++;
} while (i < 10);
No Output
10
11
Infinite loop
int i = 1;
while (i <= 3) {
int j = 1;
while (j <= 3) {
if (i == j)
break;
System.out.print(j);
j++;
}
i++;
}
123123
121
12
112233
int i = 1;
while (i <= 5) {
System.out.print(i);
if (i == 3)
break;
i++;
}
123
12345
12
Infinite loop
int i = 5;
while (i > 0) {
System.out.print(i);
i--;
if (i == 2)
break;
}
54321
543
54
5
int i = 0;
do {
System.out.print("A");
break;
} while (i < 5);
AAAAA
A
No output
Infinite loop
int i = 1;
while (i <= 3) {
System.out.print(i);
i++;
break;
}
123
1
No output
Infinite loop
