What is the result?

Given:
2. class Test {
3. public static void main(String args[]) {
4. for (int i = 1; i < 5; i++) {
5. if (i == 2) {
6. continue;
7. }
8. System.out.print(” i = ” + i);
9. }
10. }
11. }
What is the result?

Given:
2. class Test {
3. public static void main(String args[]) {
4. for (int i = 1; i < 5; i++) {
5. if (i == 2) {
6. continue;
7. }
8. System.out.print(” i = ” + i);
9. }
10. }
11. }
What is the result?

A.
i = 1 i = 3 i = 4 i = 5

B.
i = 1

C.
i = 1 i = 3 i = 4

D.
The code runs with no output.

E.
i = 1 i = 2 i = 4

F.
i = 1 i = 2 i = 4 i = 5

G.
Compilation fails.



Leave a Reply 0

Your email address will not be published. Required fields are marked *