Bird
0
0

What is the result of the expression $true -and $false in PowerShell?

easy📝 Conceptual Q2 of 15
PowerShell - Variables and Data Types
What is the result of the expression $true -and $false in PowerShell?
A$true
BFalse
C1
D0
Step-by-Step Solution
Solution:
  1. Step 1: Understand the '-and' operator

    The '-and' operator returns True only if both sides are True; otherwise, it returns False.
  2. Step 2: Evaluate the expression

    Since one side is $false, the whole expression evaluates to False.
  3. Final Answer:

    False -> Option B
  4. Quick Check:

    '-and' with one False = False [OK]
Quick Trick: '-and' returns true only if both are true [OK]
Common Mistakes:
  • Assuming '-and' returns numeric 1 or 0
  • Confusing '-and' with '-or'
  • Thinking $true -and $false returns $true

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes