This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes continue statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "continue statement" Watch "continue statement" New topic

continue statement

ketki kalkar
Ranch Hand

Joined: May 09, 2007
Posts: 36
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.
marc weber

Joined: Aug 31, 2004
Posts: 11343

Compile and run with these println statements added to the code.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
ram shah

Joined: Jun 02, 2007
Posts: 28
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

Joined: Jan 16, 2007
Posts: 4
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

Regards,<br />Gautam Arora<br />100% Geek
Don't get me started about those stupid light bulbs.
subject: continue statement
It's not a secret anymore!