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
Write a program to search a number in the given list of numbers.
How do you detect memory leaks?
What is the difference between error and an exception?
How to reverse a string in java?
What invokes a thread's run() method in java programming?
How do you compare objects in java?
What is a numeric format?
Tell us something about set interface.
What is collections framework?
What is casting in java programming?
What state does a thread enter when it terminates its processing in java programming?
What is internal iteration in java se 8?
Can we execute a program without main?
What do you mean by buffering?
What is a local block?