Difference Between An "Object" And "Variable"?

Well, It Seems like a very basic question , but i was asked this in an interview!! ๐Ÿ˜› In , Object Oriented Programming, What is the difference between an "OBJECT" And A "VARIABLE"? Does an object acts like a variable also? ๐Ÿ˜’ Both Can store data, so whats the difference? I Am feeling odd, to ask this most basic question? ๐Ÿ˜•

Replies

  • Morningdot Hablu
    Morningdot Hablu
    Hey buddy do you mean object variable.
    Because object and object variable are two different things.
  • Manish Goyal
    Manish Goyal
    Objects primarily concerned with real world entities.These are basically instance of a class.

    and variable is just a reference to memory block where data is stored .

    here both objects and variable doesn't store data both are just reference to memory block
  • bill190
    bill190
    In common terms (probably not a good enough answer for school or a job)...

    An object is a stand alone computer program which does something.

    Like you may have a computer program with a timer, a display, keyboard input, and serial communications. Some of these things can be placed in their own little "box" and used again and again for different programs. Like serial communications could be its own little box or "object".

    A variable is like a file folder in a filing cabinet. It can hold information.

    In a kitchen an object would be something like a can opener or microwave oven. Things which do something.

    And in a kitchen a variable would be like a drawer in which you can store something.

    Following is an "object exchange" for a microcontroller called a Propeller. These are software "objects" you can add on to your Propeller microcontroller that will do something. For example there is a "Full Duplex Serial" object in the Protocol area. This adds on serial communications to the microcontroller....
    #-Link-Snipped-#

    You can view these objects with the Propeller / Spin tool here...
    #-Link-Snipped-#
  • Pensu
    Pensu
    Any thing that stores the data is a variable. A variable stores a data directly but this is not the case with an object. Suppose we make a class named student and we are storing in it name,regno,year, branch etc. Now I make a object namely Peeyush, it will store all the variables i.e. name, regno, year, branch and these variables will store corresponding data.


    Correct me if i am wrong.
  • kamal_kj5
    kamal_kj5
    An Object just simply is an input data.But a variable is like a saving destination.Just as said Variable is like a file holder.But I don't agree that both can store data.Maybe they both can store data but an object is a type of data itself and it maybe stored inside the variable!
  • arunravindran
    arunravindran
    An object is a variable of a class. A variable is used to identify a memory location. Hence, an object is something that is used to identify the memory location of a class. Since class has got lots of declared variables and member functions, its used to identifies a collection of memory locations...

You are reading an archived discussion.

Related Posts

Match the following 1. urbanity -----------a. referring to the countryside 2. suburbia------------b. word with negative or derogatory connotation; 3. exurbia-------------c. to spend time in the country 4. animus-------------d. residential areas...
Hi, Yesterday only my lateral entry counselling was held for me and i got Mechanical Engineering at PSG College of Technology, Coimbatore! So any PSGian's in CE??? Be friends ๐Ÿ˜€...
Presenting July 10 Know Your CEan . This KYCean session is super lengthy ( ๐Ÿ˜) . See , Opti helped us in compensating the delay is putting up this one....
Hi Everyone! I'm final year student in EEE and I want to do Temperature Control System using LabVIEW. I'll also use Image processing in labview for that project. Temperature control...
hi everyone ! can anyone provide me the tutorial of matlab.