What is Object and Class? What are the differences between
them?
Answer Posted / pankaj vashishta
Class is template for creating similar type of entities.
Class doesn't take memory space untill it contains static
members.
In a specific Class, you declare the attributes(field
variables) and its behaviour(functions).
But Class doesn't have any state and identity.
Objects are the real time entity which are created through
their template, thier class.
By real time entity, I mean they would occupy a memory
space in which they will save the values of its atrributes.
These values create a state of an object.
Since Object occupy a space in memory so they have unique
address in memory. This become the identity of an object.
For example : Pen is a class, which has weight and color as
its attribute. They may have behaviour like write().
Still they don't occupy a space in memory.
When I say My pen ,It will be an object of class Pen since
it will have some values for weight like 10 gm and color
like blue. This will occupy some memory to save these
values.
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
when to use 'mutable' keyword and when to use 'const cast' in c++
What is encapsulation in oops?
What is class in oop with example?
What is constructor overloading in oop?
What is difference between multiple inheritance and multilevel inheritance?
to find out the minimum of two integer number of two different classes using friend function
How oops is better than procedural?
Can a varargs method be overloaded?
write string class as your own class in java without using any built-in function
Why we use classes in oop?
#include
Why do we use polymorphism?
What is overriding in oops?
What does sksksk mean in text slang?
Explain virtual inheritance?