This is for C++
The use of default in a switch-case statement is to _______.
Choices below are
Exit from the case structure.
Continue with the remaining case conditions.
Cover unhandled possibilities.
Exit from the program.
Correct Answer:
Exit from the case structure.
Explanation:
The first option is correct because if there is no match found then the default block will execute and the switch will exit.
The second option is incorrect because the default block is used to exit the switch statement but not used to continue.
The third option is incorrect because the default block is not used to cover unhandled possibilities.
The fourth option is incorrect because the default block is used to exit the switch statement but not to exit the complete program.
So, only the first option is correct.
Get Answers For Free
Most questions answered within 1 hours.