PowerShell - Variables and Data TypesWhich of the following is the correct way to create an empty array in PowerShell?A$arr = []B$arr = array()C$arr = {}D$arr = @()Check Answer
Step-by-Step SolutionSolution:Step 1: Recall PowerShell array syntaxPowerShell uses @() to create arrays, including empty ones.Step 2: Check each option$arr = @() uses @() which is correct. Options A, B, and C use invalid or different syntax for arrays.Final Answer:$arr = @() -> Option DQuick Check:Empty array = @() [OK]Quick Trick: Use @() to create arrays in PowerShell [OK]Common Mistakes:Using [] which is not valid for arrays in PowerShellUsing {} which is for hashtables or script blocksUsing array() which is not recognized in PowerShell
Master "Variables and Data Types" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Cmdlets and Pipeline - Pipeline object flow - Quiz 6medium Cmdlets and Pipeline - Sort-Object for ordering - Quiz 11easy Cmdlets and Pipeline - Sort-Object for ordering - Quiz 13medium Control Flow - For loop - Quiz 13medium Operators - Range operator (..) - Quiz 14medium Operators - Comparison operators (-eq, -ne, -gt, -lt) - Quiz 5medium PowerShell Basics and Environment - Why PowerShell exists - Quiz 4medium PowerShell Basics and Environment - PowerShell versions (5.1 vs 7+) - Quiz 4medium Variables and Data Types - Integer and floating-point types - Quiz 8hard Variables and Data Types - String type and interpolation - Quiz 3easy