Single Choice Easy

QYou need a conditional statement that checks if a variable equals “In progress,” “Completed,” or “Canceled.” Different code needs to run, depending on what the variable equals. A default block of code needs to run if the variable does not equal any of the values. What conditional statement is most appropriate?

ID: #12158 X++ Overview in D365 F&O 258 views
Question Info
#12158Q ID
EasyDifficulty
X++ Overview in D365 F&OTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Error handling
  • B A ternary operation
  • C If statement
  • D Switch statement
Correct Answer

Explanation

  • A. Incorrect: Error handling is not a conditional statement.
  • B. Incorrect: A ternary operation only checks if a value or expression is true. Based on the results, the operation takes different actions.
  • C. Incorrect: The if statement does not allow multiple branches of code depending on a value. If statements check if the expression is true or false and then runs or doesn’t run the code.
  • D. Correct: The switch statement allows you to use cases. If the case matches the value of the switch expression, then a specific code block can run. A default case can also be used when no other cases match.

Share This Question

Challenge a friend or share with your study group.