Bird
0
0

Given the code:

medium📝 Command Output Q4 of 15
PowerShell - Working with Objects
Given the code:
$a = 'apple','banana','cherry'
$b = 'banana','cherry','date'
Compare-Object -ReferenceObject $a -DifferenceObject $b

What will be the output?
Abanana <= cherry =>
Bbanana => cherry <=
Capple => date <=
Dapple <= date =>
Step-by-Step Solution
Solution:
  1. Step 1: Identify unique items in each array

    $a has 'apple' unique; $b has 'date' unique; 'banana' and 'cherry' are common.
  2. Step 2: Understand SideIndicator symbols

    '<=' means item is only in ReferenceObject ($a), '=>' means only in DifferenceObject ($b).
  3. Final Answer:

    apple <= date => -> Option D
  4. Quick Check:

    Unique items with correct SideIndicator = apple <=, date => [OK]
Quick Trick: SideIndicator <= means Reference only, => means Difference only [OK]
Common Mistakes:
  • Mixing up SideIndicator symbols
  • Listing common items as differences
  • Reversing Reference and Difference arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes