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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is indexof?

547


Is passing by reference faster?

523


what is difference between equals and ==?

590


How does callback work in java?

607


What is polymorphism in java? What are the kinds of polymorphism?

582






What do you mean by garbage collection used in java?

575


Wha is the output from system.out.println(“hello”+null); ?

696


What is the full name of java?

571


Can a top level class be private or protected?

576


What is the default execution method in java?

624


Write a program to search a number in the given list of numbers.

631


What are heterogeneous objects?

568


What is an immutable class?

616


Can we use different return types for methods when overridden?

556


What is boolean query?

532