What is the difference(or similarity if there are some)
between object and a variable?

Answers were Sorted based on User's Feedback



What is the difference(or similarity if there are some) between object and a variable?..

Answer / dipty

A variable can hold asingle type of variable at a time..but an object can hold a number of variables of different type.

int a = 4; // a would be the variable
Car b = new Car();// b is an object
b.carGo();// this is an method in the object car created below.
class Car()
{
void carGo()
{
car moves;
}
}

Is This Answer Correct ?    14 Yes 1 No

What is the difference(or similarity if there are some) between object and a variable?..

Answer / ved.b.tripahti

Variables : variables are the place holder for a particular
type of data and this type actually determine how much space
this var will take in the memory.

int varEx = 2; // here varEx is a integer type variable that
take integer literals and will be used as identifier for the
user.

Object : Object shows the behavior that a particular class
can perform.this object is a medium to access the behaviour
of class.
Object may regards as the blue print of a particular class.

Car carObj = new Car(); // carObj is the reference ID of the
Car class.

here -- new Car() is the actual object that will be created
by JVM.

Note :- Object always created using - new keyword.the
identifier before =, is the reference id of new Car() object,
carObj is not the actual object itself.

Is This Answer Correct ?    2 Yes 0 No

What is the difference(or similarity if there are some) between object and a variable?..

Answer / udayasri

Variable: Variable is a value which is change during the run
time of the program, and it allocates the memory space for
the particular data type which we mention as var = "something"
Object: Object is the blue print of the class i.e. it shows
the behavior of the class. It creates memory for that whole
class and even class is refer by this object only.

Is This Answer Correct ?    1 Yes 2 No

What is the difference(or similarity if there are some) between object and a variable?..

Answer / ameca1

What I know is all variables are objects but not the reverse
. . .

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More Core Java Interview Questions

Can we print null in java?

0 Answers  


what is an virtual function

2 Answers   TCS,


Is sizeof a keyword in java programming?

0 Answers  


Explain the init method?

0 Answers  


Why do you canvas?

0 Answers  






Which method returns the length of a string?

0 Answers  


What is meant by Servelet? What are the parameters of service method?

2 Answers  


Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.

0 Answers   Rolta,


Need 2+ yrs experienced java techinical question papaer for company Iflex

1 Answers   TCS,


C and C++ has constructors and distructors, why does Java does not have distructors?

1 Answers   T3 Softwares,


what is a thread?

13 Answers   IBM, SunGard,


What is substring of a string?

1 Answers  


Categories