SCJP Module-5 Question-14

The program given below will test your understanding about the continue key word in Java.

 
 

Share on Google+Share on Google+

SCJP Module-5 Question-14

Ads

The program given below will test your understanding about the continue key word in Java.

Given a sample code:

1    public class Test2 {
2    public static void main(String[] args) {

3    int i = 3;
4    System.out.println("start");
5    switch (i) {
6    case 3:
7    continue;
8    case 4:
    }
9    System.out.println("end");
    }}

What will be result when compiled and run?

(A)  start
(B)  end   
(C)  start end  
(D)  Compilation error at line no-7.   

Answer:

(D)

Explanation:

continue cannot be used outside of a loop

Advertisements

Posted on: July 22, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles