Home Tutorial Java Scjp Part2 SCJP Module-2 Question-12

 
 

Share on Google+Share on Google+
SCJP Module-2 Question-12
Posted on: July 8, 2010 at 12:00 AM
Advertisement
The given sample program below checks the knowledge of for loop and flag in Java.

What is the output of the following 'for' loop code :

public class Example12 {
public static void main(String[] args) {
int a, b;
flag: for (a = 0; a < 6; a++) {
for (b = 5; b > 2; b--) {
if (a == b) {
System.out.print(" " + b);
continue flag;
}
}
}

}
}}

What is the output of the given below 'for' loop code :

1.  5

2.  compile error

3.  5  4

4.  5  4 3

Answer :

(4)

Advertisement

Related Tags for SCJP Module-2 Question-12:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 8, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com