Difference between while() and do… while() ?

while() do… while()
1. In while loop test-condition appears at the beginning of the loop. 1. In do-while loop test-condition appears at the end of the loop
2. It is also known as Entry-controlled loop 2. It is also knwon as Exit-controlled loop
3. The control do not enters the body of while loop when the test-condition gets false 3. The control enters the body of do-while loop at least once even if test-condition gets false
4. Semi-colon(;) is not used with while statement 4. Semi-colon(;) is used with do-while statement
Syntax:
while (test-condition){
statement 1;
statement 2; // body of the loop
}
Syntax:
do{
statement 1;
statement 2;// body of do-while loop
} while(test-condition);

Difference between break and continue (java jump statements)?

break continue
1. break is used to exit a loop or switch case block. 1. continue is used to to move the control again to the current loop./td>
2. break stops the continuation of the loop. 2. continue do not stops the continuation of the loop, it only stops the current iteration.
3. break can be used with switch statement or label. 3. continue cannot be used with switch statement or label.
4. It causes early termination of loop. 4. It causes early execution of next iteration.
5. Example:
for(i=1;i<=5;i++){
System.out.println(i);
if(i==4)
break;}
Output:
1
2
3
5. Example:
for(i=1;i<=5;i++){
if(i==4)
continue;
System.out.println(i);
}
Output:
1
2
3
5

Difference between if else and switch case statements ?

break continue
1. break is used to exit a loop or switch case block. 1. continue is used to to move the control again to the current loop./td>
2. break stops the continuation of the loop. 2. continue do not stops the continuation of the loop, it only stops the current iteration.
3. break can be used with switch statement or label. 3. continue cannot be used with switch statement or label.
4. It causes early termination of loop. 4. It causes early execution of next iteration.
5. Example:
for(i=1;i<=5;i++){
System.out.println(i);
if(i==4)
break;}
Output:
1
2
3
5. Example:
for(i=1;i<=5;i++){
if(i==4)
continue;
System.out.println(i);
}
Output:
1
2
3
5