Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - Working with Objects
What will be the output of this PowerShell code?
$obj = "hello"
$obj.GetType().Name
AObject
BGetType
Chello
DString
Step-by-Step Solution
Solution:
  1. Step 1: Understand GetType() method

    GetType() returns the type information of the object.
  2. Step 2: Check the type of a string literal

    "hello" is a string, so GetType().Name returns "String".
  3. Final Answer:

    String -> Option D
  4. Quick Check:

    GetType().Name = B [OK]
Quick Trick: GetType().Name shows the object's type name [OK]
Common Mistakes:
  • Expecting the value instead of type name
  • Confusing method name with output
  • Thinking output is 'Object'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes