21.) Which of the following statements is true about the “if” statement?
A) The “if” statement can exist without the “else” statement.
B) The “else” statement can exist without the “if” statement.
C) Both “if” and “else” statements are mandatory in any program.
D) The “if” statement is optional and can be omitted.
22.) Which of the following statements is true about the “do-while” loop?
A) It may execute zero or more times.
B) It always executes at least once.
C) It executes a specific number of times.
D) It’s used exclusively for iterating through arrays.
23.) In a switch-case statement, can the same value appear in multiple case blocks?
A) Yes, but only if they are adjacent to each other.
B) No, each value must appear only once in the entire switch-case.
C) Yes, it’s allowed to have the same value in different case blocks.
D) It depends on the specific Java version.
24.) Which loop control statement transfers control to the loop’s condition evaluation?
A) continue
B) break
C) goto
D) exit
25.) What is the main purpose of the “break” statement in a switch-case statement?
A) To compare the value of the expression.
B) To terminate the entire program.
C) To skip the current case and proceed to the next case.
D) To exit the loop or switch-case statement.
26.) In a “do-while” loop, when is the loop condition evaluated?
A) Before executing the loop body
B) After executing the loop body
C) Before and after executing the loop body
D) The “do-while” loop doesn’t have a condition.
27.) The __ statement at the end of each block signals the end of a particular case and causes an exit from the switch statement, transferring the control to the statement following the switch.
A) switch
B) break
C) continue
D) default
28.) The __ statement tests the value of a given variable against a list of case values and when a match is found, a block of statements associated with that case is executed.
A) default
B) break
C) continue
D) switch