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
What is space character in java?
What is lifetime variable?
What modifiers may be used with a top-level class?
What is java life cycle?
Can sleep() method causes another thread to sleep?
What is an array in java?
Can a constructor have different name than a class name in java?
What are the differences between heap and stack memory in java?
Why hashset is used in java?
Why is multithreading important?
Is void a type?
What is a qms manual?
Which sort is best in java?
what happens when a thread cannot acquire a lock on an object? : Java thread
Can an object subclass another object?