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

 
 

Share on Google+Share on Google+
SCJP Module-2 Question-14
Posted on: July 8, 2010 at 12:00 AM
Advertisement
A sample program given below checks your knowledge of outer key word and while loop in java and also helps in preparation for SCJP examination

What is the outcome of the following code :

class Example14 {
public static void main(String[] args) {
int a = 1;
int b = 2;
outer: while (a < b) {
++a;
inner: do {
++b;
if (b % 3 == 0)
continue outer;
if (a % 3 == 1)
break outer;
System.out.println(a * b);
} while (b < a);
System.out.println(a+ b);
}
}
}

Given below a code ,which have one outer loop 'while' & one inner loop 'do ..while' .Find it's output :

1. compile error

2. 12

3. 12  7

4. 7

Answer :

(3)

Advertisement

Related Tags for SCJP Module-2 Question-14:


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