-
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? 😕0
-
Member • Jul 19, 2010
Hey buddy do you mean object variable.
Because object and object variable are two different things.Are you sure? This action cannot be undone. -
Member • Jul 19, 2010
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 blockAre you sure? This action cannot be undone. -
Member • Jul 22, 2010
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-#Are you sure? This action cannot be undone. -
Member • Jul 22, 2010
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.Are you sure? This action cannot be undone. -
Member • Jul 30, 2010
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!Are you sure? This action cannot be undone. -
Member • Aug 1, 2010
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...Are you sure? This action cannot be undone.