• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

continue statement

 
ketki kalkar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which all lines are part of the output when the following code is compiled and run. Select all correct answers.

public class test {
public static void main(String args[]) {
outer: for(int i = 0; i < 3; i++)
for(int j = 3; j >= 0; j--) {
if(i == j) continue outer;
System.out.println(i + " " + j);
}
}
}
}


a. 0 0
b. 0 1
c. 0 2
d. 0 3
e. 1 0
f. 1 1
g. 1 2
h. 1 3
i. 2 0
j. 2 1
k. 2 2
l. 2 3
m. 3 0
n. 3 1
o. 3 2
p. 3 3

answer is b,c,d,g,h,l.
How?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compile and run with these println statements added to the code.
 
ram shah
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the output should be in the order,
d,c,b,h,g,l as i is incremented and j is decremented.

Am i correct? I'm at work. so, can't compile & check.
 
Gautam Arora
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the question asks you to enter select all correct options and not the specific order (though the order you have given is correct).

Just curious, why cant you compile a program at work. I would guess that you are a programmer and should have access to javac and java
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic