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


Please Help Members By Posting Answers For Below Questions

What is encapsulation in simple terms?

780


What is an advantage of polymorphism?

826


write string class as your own class in java without using any built-in function

2221


what is different between oops and c++

2203


What are two types of polymorphism?

814


What are the data types in oop?

833


What are main features of oop?

877


Why do we need oop?

882


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

1855


What is oops with example?

780


what is graphics

2214


How do you achieve polymorphism?

829


Write a program to sort the number with different sorts in one program ??

2112


What is oops concept with example?

772


How to use CMutex, CSemaphore in VC++ MFC

4545