This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
When is it appropriate to use a switch-case construct rather than a if-elseif-else construct?
switch-case
if-elseif-else
A switch-case construct is appropriate when more than 2-3 else if code blocks are required.
else if
A switch-case construct is appropriate when the number of case patterns is small.
case
A switch-case construct is appropriate when the selection statement is inside a loop.
Why should a developer choose a for statement rather than a foreach statement when processing the contents of a multidimensional array?
for
foreach
for statements do a better job of examining each array item separately.
foreach statements do a better job of examining each array item separately.
for statements enable a developer to treat array dimensions separately.
Why is it important to scope a variable at its lowest necessary level?
It ensures that a variable that's declared outside of a code block, can be accessed inside the code block before it's been assigned a value.
It ensures that application resources and the security footprint are kept small.
It ensures that a variable can be accessed within the lowest level code branches of an application.
You must answer all questions before checking your work.
Continue
Was this page helpful?