Card 18 / 76: Which conditional statement would be best suited for determining the flow of code based on an int that may have a value between 1 and 10? The program must react differently for each value.
A)
if-else statement
B)
if-else-if statement with multiple if-elses
C)
multiple if statements
D)
switch statement
Answer:
D) switch statement
Previous Card | ← Previous Card Button |
Next Card | → Next Card Button |
Flip Card | Space-Bar |
A, B, and C are incorrect.
A is incorrect because the if-else statement only allows two conditions and this question calls for ten conditions.
B and C are incorrect because a combination of if statements should be used only when limited conditions are being checked.
|