Which of this statement is incorrect?
a) switch statement is more efficient than a set of nested ifs
b) two case constants in the same switch can have identical values
c) switch statement can only test for equality, whereas if statement can
evaluate any type of boolean expression
d) it is possible to create a nested switch statements
Answers
Answered by
15
Answer:
b) two case constants in the same switch can have identical values
Answered by
7
Option (b) two case constants in the same switch can have identical values is an incorrect statement.
Explanation:
- A switch statement allows you to compare a variable to a list of values for equality. Each value is referred to as a case, and each case is examined separately.
- A multi-way branch statement is a switch statement. It makes it simple to delegate execution to different areas of the program based on the expression's value.
- Duplicate case values aren't permitted in Switch statements. Two case constants in the same switch should not have the same value. A compile-time error occurs when a value is duplicated.
Similar questions