Monday, January 3, 2011

What is an Instance?


     An instance has state, behavior and identity. The structure and behavior of similar classes are defined in their common class. An instance is also called as an object.

       Instance is nothing but objects in a class.Its just like students in a particular class having, just like different , height, weight, color, etc Means which can hold separate properties and behavior.

        An instance (also sometimes called an object) is when you use a class (or any other type) to allocate space on the stack, or the heap, and call the class's constructor. 

         If their was a class named Person. It might have instance variables for each person's weight. It might have a class variable for the common belly-button count for all Persons.

No comments:

Post a Comment