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
What is multilevel inheritance explain with example?
Why do pointers exist?
#include
What is polymorphism oop?
What is difference between inheritance and polymorphism?
Why it is called runtime polymorphism?
What is byval and byref? What are differences between them?
What is destructor give example?
Can you inherit a private class?
What is overloading in oops?
what are the different types of qualifier in java?
Can a varargs method be overloaded?
What is persistence in oop?
Why is oop useful?
How to call a non virtual function in the derived class by using base class pointer