Aug 13, 2015

what is the difference between class and objects?

Class is conceptual thinking about real world entity whereas object is a physical existence. Ex.
Person is a class and I am the object of person class I have all the properties and behavior of person class. 


For Example, Shape may be a class and Triange and Square are objects. We can take "Side" as a field and "Area" as a method. So Area takes the Side and calculates the Area of that particular shape.

Class is a type which is logical and not physical. Object is the physical form a class type where memory allocation is done. In a simple terms it is a blue print or structure of the object and object is the actual representation of the type.  


Class is user defined data type it contain data member and funciton.
object is real time entity . 


Class is a collection of data members and methods. Object is an instance of a class.
class is only declaration.While object is actual creation of memory space for that declaration.


 

No comments:

Post a Comment