Bird
0
0

What will this PowerShell function output?

medium📝 Command Output Q5 of 15
PowerShell - Functions
What will this PowerShell function output?
function Test-Return {
  5
  return 7
  9
}
Test-Return
A5 7
B5
C7
D9
Step-by-Step Solution
Solution:
  1. Step 1: Understand implicit output before return

    The number 5 is output because it is the first command and no return has occurred yet.
  2. Step 2: Analyze the return statement

    Return 7 outputs 7 and exits the function immediately, so 9 is ignored.
  3. Final Answer:

    5 7 -> Option A
  4. Quick Check:

    Output before return + return value = combined output [OK]
Quick Trick: Commands before return output; return exits function [OK]
Common Mistakes:
  • Ignoring output before return
  • Expecting only return value output
  • Thinking code after return runs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes