One day on my class, I asked a question to students, What is a class? Everyone came up with a definition. One popular definition was "A class is a group of objects". I stunned at this answer. This was a definition stated in text book.
I started to explain the definition, "A class is s group of objects". I showed them a pen and told them that the pen is an object. All agreed. Then I showed three pens, so a group of pen, a group of objects.
If so, then the three pens should be called as a class.
Huh..
It is not. It is absolutely wrong understanding....
Then what is a class..
A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.
I need to explain this further.
For example, take any object say a table. It has so many characteristics. Let me specify some of those.
So we can form a class like the following
Class Table{
I started to explain the definition, "A class is s group of objects". I showed them a pen and told them that the pen is an object. All agreed. Then I showed three pens, so a group of pen, a group of objects.
If so, then the three pens should be called as a class.
Huh..
It is not. It is absolutely wrong understanding....
Then what is a class..
A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations.
I need to explain this further.
For example, take any object say a table. It has so many characteristics. Let me specify some of those.
- Color of the table.
- Size of the table.
- Price
- No. of Legs.
So we can form a class like the following
Class Table{
- Color
- Size
- Price
- NoOfLegs
No comments:
Post a Comment