Recall & Review
beginner
What is the
object type in C#?The
object type is the universal base type in C#. Every type, whether value or reference, directly or indirectly inherits from object.Click to reveal answer
beginner
Can a variable of type
object hold any data type in C#?Yes, a variable of type
object can hold any data type because all types derive from object. This allows storing any value or reference type in an object variable.Click to reveal answer
intermediate
What happens when you assign a value type to an
object variable?The value type is 'boxed' — it is wrapped inside an object on the heap so it can be treated as a reference type.
Click to reveal answer
intermediate
How do you get the original value back from an
object variable holding a value type?You perform 'unboxing' by casting the
object back to the original value type.Click to reveal answer
beginner
Why is
object useful as a universal base type?Because it allows writing flexible code that can work with any data type, enabling polymorphism and generic programming.
Click to reveal answer
Which type is the universal base type for all types in C#?
✗ Incorrect
In C#,
object is the universal base type from which all types derive.What is boxing in C#?
✗ Incorrect
Boxing is wrapping a value type inside an
object so it can be treated as a reference type.How do you retrieve the original value type from an object variable?
✗ Incorrect
Unboxing is casting the
object back to the original value type.Can an
object variable hold a string value?✗ Incorrect
Strings are reference types and derive from
object, so they can be stored in an object variable.Why might you use
object as a variable type?✗ Incorrect
Using
object allows storing any type of data because all types derive from it.Explain how the
object type acts as a universal base type in C# and what happens when you assign a value type to an object variable.Think about how value types are wrapped when assigned to object.
You got /3 concepts.
Describe the difference between boxing and unboxing in C# with examples.
Boxing and unboxing are about converting between value types and object.
You got /3 concepts.