Break & Continue Practical

Advertisements
Advertisements
Advertisements3
Advertisements4
Advertisements6
Advertisements66

 1. What is the output of the given code?

public class Test{

    public static void main(String []args){
        for(int i = 0; i < 10; i++){
            if(i % 2 == 0){
                continue;
            }
            System.out.println(i);
        }
    }
}

Ans. program will print all odd numbers between 0 to 10.

2. Where can the “break” statement be used in Java?

Ans. Inside both a loop and switch statement.

 

 

Author: Lakshmi Prasanna Ponnala

Completed M.Tech in Digital Electronics and Communication Systems.

Leave a Reply

error: Content is protected !!

Discover more from ece4uplp

Subscribe now to keep reading and get access to the full archive.

Continue reading