ExamVeda
Login
Home
This question belongs to Java Program Flow Control
Flow Control
?

Determine output:
public class Test{
        public static void main(String args[]){
                int i; 
                for(i = 1; i < 6; i++){ 
                        if(i > 3) continue ; 
                }
                System.out.println(i); 
        }
}

Answer & Solution
Correct Answer: Option E
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

8 Comments
Ajay Bade
Ajay Bade 5 years ago
Ans 6 is correct because the println statement out of the for loop .first start the program i=1 inter in for loop but condition is i > 3 so counter will be increment and again enter in the loop the condition is false i will increment and again enter loop i = 3 but condition is false when i will be 4 the the i will continue and same as i = 6 loop condition is false the the i value is 6 thats why the i printed 6
Thirupath Reddy
Thirupath Reddy 6 years ago
any one can explain i didn't understand
Rishi Guha
Rishi Guha 6 years ago
The Answer will be 6, because if you look at the if statement it basically does nothing. The continue statement just iterates through the loop and increments the value of i. When i = 6 the loop terminates and S.O.P is executed.
Pinaki Chakraborty
Pinaki Chakraborty 7 years ago
Ans is 2 , because if condition always skip values which is greater so 6 is skip value.
Sasi Rekha
Sasi Rekha 8 years ago
Your Ans is wrong ..the Ans is 2...because if condition skip the values which are having greater than 3
Rohan Pawar
Rohan Pawar 8 years ago
how come the answer corresponds to 6 when i
Chaitanya V.
Chaitanya V. 9 years ago
Somebody help. I'm unable to understand why if condition is not evaluated.
Whispher Eyes
Whispher Eyes 10 years ago
why we use here if condition while there is no effects it on there?