Give brief description about class?

Showing Answers 1 - 2 of 2 Answers

vishnu bobade

  • Sep 8th, 2005
 

Classes are the heart and soul of an object-oriented language. You will find yourself using classes whenever you write even the simplest of programs in Visual Basic  
Wrapping up the representation and set of operations you perform on a database table, for example adding, editing, deleting, and retrieving data.  
Wrapping up the set of operations and data for dealing with text files such as reading, writing, and indexing the lines of text within the file.  
Wrapping up all global variables in a program into properties within a class. This can help with keeping track of the amount of "free-floating" globals that somehow seem to work their way into many programs.  

  Was this answer useful?  Yes

geekspv

  • Oct 31st, 2005
 

A Class is a template of an object. Let us understand this in detail with a sample object pen.

We can list out the various characteristic features of the pen as

* It is of various types: Fountain pen, Ball-point pen, Flourescent pen, etc.
* It has a base body and cap
* It has a grip to hold while writing
* It has a clip enabling clipping to pocket
* It has a refill-tank
* The ink is of some colour

The above features are all common to various types of pen be it Ball-point, Fountain, or Flourescent
Instead of the word features, the word properties would best suit. Agree?

Now let us analyse what are the actions performed by this object 'pen'. We will immediately strike the very usage of it is 'to write'.
Is that all....

Let me list out some more

* Open Cap
* Write
* Close Cap
* Refill

Now, we can conclude that the pen (object) has

 * features or properties
 * actions or functions (often referred to as methods)

Each time instead of reading detailed specification of these properties and functions for each type of pen, when the object name 'pen'
is heard, all the above are recollected in our memory. Hence, a common structure can be framed that can combine both properties and functions.

 PEN
 {
  properties:
   type,
   size,
   ink-colour,
   clip (Y/N),
   refill tank capacity (ml)
  
   
  functions:
   OpenCap
   Write
   CloseCap
   Clip
   Refill
 }

   
The properties are simply generic names for the data to be held such as
 type:  Fountain, Ball-point, etc
 size:  5", 3", 8", etc.
 ink-colour: blue, black, red, green, etc.
 clip:  Yes
 refill tank capacity: 2 ml, 3 ml, etc.

Also the functions are some kinds of actions that use or manipulate the data (or properties)

Finally, in the OOP technology the term class is used for this kind of structure/template for an object. Using this template 'n' number of copies can be generated. Each of these copies is known as an object of that class.

Hence, a class is a generic/skeletal representation of an object, while an object is the exact copy of the class that actually can used to perform activity.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions