Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
What is the output of the following program?
public class Main {public static void main(String[] args) {int i = 5;while(i < 10) { System.out.print(i + " "); i++; } }}
5 6 7 8 9
6 7 8 9 10
5 6 7 8 9 10
None of the above
==
!=
<=
><
A while loop runs at least once, while a do-while loop may not run at all.
A while loop always runs exactly once, while a do-while loop may run more than once.
A while loop tests its condition at the beginning of the loop, while a do-while loop tests its condition at the end of the loop.
A while loop is used for iterating over arrays, while a do-while loop is used for iterating over collections.
It terminates the current loop or switch statement.
It skips the remaining statements in the current iteration of the loop.
It jumps to a specific label in the code.
It creates a new loop or switch statement.
continue
break
return
goto
skip
while loop
do-while loop
for loop
if statement
public class Main {public static void main(String[] args) {int i = 0;do { System.out.print(i + " "); i++;} while(i < 5);}}
0 1 2 3 4
1 2 3 4 5
0 1 2 3 4 5
To define a new variable in the code.
To provide a descriptive name for a loop or if statement.
To mark a specific point in the code that can be jumped to using the goto statement.
To create a custom exception class.
Nested loops can only be used with for loops, not with while or do-while loops.
A break statement inside a nested loop terminates only the innermost loop.
A continue statement inside a nested loop skips only the innermost loop.
Nested loops are never used in real-world programming.