9
Reply

what is the difference between class and objects?

Sri Chandra

Sri Chandra

14y
5k
0
Reply

    Please refer to the following URL to know the differences between Class and Object,http://onlydifferencefaqs.blogspot.in/2012/07/oops-difference-faqs-2_11.html

    Class is a collection of Objects, and object is an instance of a Class.

    Hi,

    If you have sub class version method too, then need to elaborate the design by adding one interface which will hold all of your such methods, like below. This design can apply to any of your sub class by just implementing this interface.

    public class MyAbstractChild : MyAbstract,ICommon

    {

    public void CallMyAbstractMethod()

    {

    //Subclass version will be called

    ICommon obj = new MyAbstractChild();

    obj.MyAbstractMethod();

     

    //Main abstract class version will be called

    MyAbstract obj1 = new MyAbstractChild();

    obj1.MyAbstractMethod();

    }

    public new void MyAbstractMethod()

    {

    Console.WriteLine("I am abstract child");

    }

    }

    public abstract class MyAbstract : ICommon

    {

    public void MyAbstractMethod()

    {

    Console.WriteLine("I am abstract");

    }

    }

    public interface ICommon

    {

    void MyAbstractMethod();

    }

     

     

     

    CLASS  is a user defined data type  and store in heap.   two types of data type value types and reference typew .  in value types stored in stack and when we defined user defined data type it actually store the memory address. and  classes gives resuablity security  and code access security.

    and when we create the  class when we declare object memory is allocated to this variable. so when we create the class of an object it is object is instiated by new operator.

     

    A class is basically a definition, and contains the object's code. An object is an instance of a class.

    14y
    0

    A Class is collection of attributes(fields) and methods and this methods works on the data. The enitre class is encapsulated and is represented as a single unit. But again Class is a model only that describes about how class methods works on the class attributes.

    When this class takes the shape of  a real world thing, that time we say the class exists and we called it as Object. So Objects are real life implementation or programmatically instatiation of the 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 blueprint and Object is the living instance of class.

     class is an abstract description of a set of objects,and Object is an instance of class...

    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.