Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
while loop
do-while loop
for loop
if statement
A switch statement can only test for equality, while if-else statements can test for any condition.
A switch statement can test for any condition, while if-else statements can only test for equality.
A switch statement is more efficient than a series of if-else statements for testing a single variable against multiple values.
There is no difference between a switch statement and a series of if-else statements.
continue
break
return
skip
goto
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.
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.
==
!=
<=
><
What is the output of the following program?
public class Main {public static void main(String[] args) {int i = 0;while (i < 10) { i++; if (i % 2 == 0) { continue; } System.out.print(i + " ");}}}
2 4 6 8 10
1 3 5 7 9
2 4 6 8
1 3 5 7
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
None of the above
It is optional, and is executed if none of the cases match the tested value.
It is mandatory, and must be the last case in the switch statement.
It is executed if the tested value matches any of the cases in the switch statement.
It is used to declare a default value for a variable.