Bird
0
0

Why does Measure-Object return 0 for the Sum property when applied to an empty list?

hard📝 Conceptual Q10 of 15
PowerShell - Working with Objects
Why does Measure-Object return 0 for the Sum property when applied to an empty list?
ABecause it returns null instead of zero
BBecause Measure-Object throws an error on empty input
CBecause the sum of no numbers is zero by definition
DBecause it counts the number of objects, not sums
Step-by-Step Solution
Solution:
  1. Step 1: Understand sum behavior on empty sets

    Mathematically, the sum of zero numbers is zero, so Measure-Object returns 0 for Sum on empty input.
  2. Step 2: Confirm Measure-Object behavior

    Measure-Object does not throw an error or return null; it returns 0 for Sum and 0 for Count on empty input.
  3. Final Answer:

    Because the sum of no numbers is zero by definition -> Option C
  4. Quick Check:

    Empty input sum = 0 by math [OK]
Quick Trick: Sum of empty list is zero, not error or null [OK]
Common Mistakes:
  • Expecting error on empty input
  • Thinking sum is null
  • Confusing sum with count

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes