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

 
 

SCJP Module-5 Question-4
Posted on: July 12, 2010 at 12:00 AM
This program will test your understanding of do while loop and its flow in Java and will help you for preparation of SCJP examination.

Given a sample code:

1    public class Test {
2    public static void main(String args[]) {
3    int i = 5;
4    do {
5    i--;
6    } while (i > 2);
7    System.out.println(i);
8    }}

What will be the result of above code ?

(1) 1
(2) 2
(3) 4
(4) The program compilation fails because of line number 6.

Answer:

(2)

Related Tags for SCJP Module-5 Question-4:


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.