Q.1 Which of the following is a selection statement in Java?
A)
if()
B)
for()
C)
break
D)
None of these
Discuss it
Explanation
Selection statements like 'if' and 'switch' are used to control the flow of a program based on a condition.
View Solution
Q.2 Which of the following is an iterative statement in Java?
A)
if()
B)
for()
C)
break
D)
None of these
Discuss it
Explanation
Iterative statements, or loops, like 'for', 'while', and 'do-while' are used to repeat a block of code.
View Solution
Q.3 Which of the following is an entry-controlled loop?
A)
while()
B)
do while()
C)
break()
D)
None of these
Discuss it
Explanation
In an entry-controlled loop, the condition is evaluated before the execution of the loop body.
View Solution
Q.4 Which of the following is an exit-controlled loop?
A)
while()
B)
do while()
C)
break()
D)
None of these
Discuss it
Explanation
In an exit-controlled loop like 'do-while', the loop body is executed at least once before the condition is checked.
View Solution
Q.5 What is the correct syntax of a While loop?
A)
initialization; while (condition) { body; increment/decrement; }
B)
increment/decrement; initialization; while (condition) { body; }
C)
(initialization value ;condition;increment/decrement)
D)
None of these
Discuss it
Explanation
The standard structure involves initializing a variable, checking the condition in the while header, and updating the variable inside the block.
View Solution
Q.6 True or False: The switch statement does not require a break statement.
A)
True
B)
False
C)
None of these
D)
N/A
Discuss it
Explanation
While technically it compiles without breaks, a break is functionally required to prevent 'fall-through' to the next case.
View Solution
Q.7 True or False: The while loop repeats a set of code while the condition is false.
A)
True
B)
False
C)
None of these
D)
N/A
Discuss it
Explanation
A while loop repeats its code block only as long as the specified condition remains true.
View Solution
Q.8 True or False: The do-while loop repeats a set of code at least once before the condition is tested.
A)
True
B)
False
C)
None of these
D)
N/A
Discuss it
Explanation
Because the condition is checked at the end of the block, the do-while loop always executes its body at least once.
View Solution
Q.9 True or False: The for loop repeats a set of statements a certain number of times until a condition is matched.
A)
True
B)
False
C)
None of these
D)
N/A
Discuss it
Explanation
The for loop is ideal when the number of iterations is known or depends on a specific counter/condition.
View Solution
Q.10 Which of the following will execute the body even when the condition controlling the loop is initially false?
A)
switch
B)
if
C)
for
D)
None of these
Discuss it
Explanation
Based on the provided answer key, switch is identified; normally, among actual loops, the 'do-while' loop is the one that executes at least once regardless of the condition.
View Solution