Home Tutorial Java Scjp Part5 SCJP Module-5 Question-12

 
 

SCJP Module-5 Question-12
Posted on: July 22, 2010 at 12:00 AM
The program given below will test your understanding about the loops and break key word in Java.

Given a sample code:

1    public class Test2 {
2    public static void main(String[] args) {
3    int i = 1;
4    for (; i <= 10; i++) {
5    if (i > 7)
6    break;
    }
7    System.out.println(i);
}}

What will be result when compiled and run?

(A)  7
(B)  8   
(C)  8 9 10   
(D)  Compilation error at line no-4.   

Answer:

(B)

Related Tags for SCJP Module-5 Question-12:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.