Advertisement

Java Loops Practice MCQs with Answers for Students

1.Which loop is used when the number of iterations is known?





2. Which loop checks the condition before execution?





3. Which loop executes at least once?





4. What is the correct syntax of a for loop?





5.What will be the output?

for(int i = 1; i <= 3; i++){ 
System.out.print(i); }




6. What is the output?

int i = 1;
while(i <= 3){
System.out.print(i);
i++;}




7. What happens if the condition in a while loop is always true?





8. Which loop is best for menu-driven programs?





9. What does break do inside a loop?





10. What does continue do?





11. What will be the output?

for(int i = 0; i < 3; i++){
System.out.print("Hi ");
}




12. What is the output?

int i = 5;
do{
System.out.print(i);
i++;
}while(i < 5);




13. Which loop is entry-controlled?





14. Which loop is exit-controlled?





15. What will be the output?

for(int i = 1; i <= 3; i++){
if(i == 2){
continue;
}
System.out.print(i);
}




Wait for 20 seconds...

Post a Comment

0 Comments