Bird
0
0

Which of the following statements about the return keyword in PowerShell is TRUE?

easy📝 Conceptual Q2 of 15
PowerShell - Functions
Which of the following statements about the return keyword in PowerShell is TRUE?
AIt can only return string values
BIt only works at the end of the script, not inside functions
CIt prints the value but does not exit the function
DIt immediately exits the function and returns the specified value
Step-by-Step Solution
Solution:
  1. Step 1: Understand the behavior of the return keyword

    The return keyword immediately stops function execution and sends back the specified value.
  2. Step 2: Evaluate the incorrect options

    Return works inside functions, exits immediately, and can return any type, not just strings.
  3. Final Answer:

    It immediately exits the function and returns the specified value -> Option D
  4. Quick Check:

    Return exits function with value [OK]
Quick Trick: Return exits function immediately with value [OK]
Common Mistakes:
  • Thinking return only prints value
  • Believing return works only at script end
  • Assuming return only returns strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes