I have been interviewed by many people in my life. Interviewers often go with simple root level questions like what is an object.
Many candidates often get confused with simple questions ! One of them is given below..

Object — Definition and Small Explaination

1. Object is a concrete entity that exists in time and space.

2. An object has 3 things.

a) State
b) Behaviour
c) Identity

3. The state and behaviour of similar objects are defined in their common class.

4. The words Instance and objects are interchangeable.

5. State of an object consists of properties i.e member variables with their dynamic values.

6. Behaviour means how an object reacts and acts when state changes and message passing. Behaviour means functions or methods defined in a class.

7. Identity is the property of an object which distinguishes it from all other objects.

8.A class or struct definition is like a blueprint that specifies what the type can do.

9. An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class.

10.Objects are also called instances, and they can be stored in either a named variable or in an array or collection. Client code is the code that uses these variables to call the methods and access the public properties of the object.

11.In an object-oriented language such as C#, a typical program consists of multiple objects interacting dynamically.

12. Please go through the example given taken from MSDN.

// keyword_object.cs
using System;
class SampleClass
{
public int i = 10;
}

class MainClass
{
static void Main()
{
object a;
a = 1; // an example of boxing
Console.WriteLine(a);
Console.WriteLine(a.GetType());
Console.WriteLine(a.ToString());

a = new SampleClass();
SampleClass classRef;
classRef = (SampleClass)a;
Console.WriteLine(classRef.i);
}
}

Output
1
System.Int32
1
10

—————

Pawan Kumar

Pawankkmr@hotmail.com