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 a nested class?

587


Explain the difference between abstract classes and interfaces in java?

594


What is the significance of java packages?

609


Explain about doubly linked list

612


Why pointers are not used in java?

577






How do you sort in ascending order in java?

516


What is the function of static in java?

535


What is the final method?

595


Can a source file contain more than one class declaration?

508


Is it compulsory for a try block to be followed by a catch block in java for exception handling?

589


What are locale settings?

544


What is the use of jtable?

648


Is java pass by value or pass by reference?

533


what is enumset?

578


Write a program in java to establish a connection between client and server?

503